func TestPolymorphismGetComposedWithDiscriminator(t *testing.T) {
	client := newPolymorphismClient()
	result, err := client.GetComposedWithDiscriminator(context.Background(), nil)
	if err != nil {
		t.Fatal(err)
	}
	if r := cmp.Diff(result.DotFishMarket, DotFishMarket{
		Fishes: []DotFishClassification{
			&DotSalmon{
				DotFish: DotFish{
					FishType: to.StringPtr("DotSalmon"),
					Species:  to.StringPtr("king"),
				},
				Location: to.StringPtr("australia"),
				Iswild:   to.BoolPtr(false),
			},
			&DotSalmon{
				DotFish: DotFish{
					FishType: to.StringPtr("DotSalmon"),
					Species:  to.StringPtr("king"),
				},
				Location: to.StringPtr("canada"),
				Iswild:   to.BoolPtr(true),
			},
		},
		Salmons: []*DotSalmon{
			{
				DotFish: DotFish{
					FishType: to.StringPtr("DotSalmon"),
					Species:  to.StringPtr("king"),
				},
				Location: to.StringPtr("sweden"),
				Iswild:   to.BoolPtr(false),
			},
			{
				DotFish: DotFish{
					FishType: to.StringPtr("DotSalmon"),
					Species:  to.StringPtr("king"),
				},
				Location: to.StringPtr("atlantic"),
				Iswild:   to.BoolPtr(true),
			},
		},
		SampleFish: &DotSalmon{
			DotFish: DotFish{
				FishType: to.StringPtr("DotSalmon"),
				Species:  to.StringPtr("king"),
			},
			Location: to.StringPtr("australia"),
			Iswild:   to.BoolPtr(false),
		},
		SampleSalmon: &DotSalmon{
			DotFish: DotFish{
				FishType: to.StringPtr("DotSalmon"),
				Species:  to.StringPtr("king"),
			},
			Location: to.StringPtr("sweden"),
			Iswild:   to.BoolPtr(false),
		},
	}); r != "" {
		t.Fatal(r)
	}
}
GetComposedWithDiscriminator - Get complex object composing a polymorphic scalar property and array property with polymorphic element type, with discriminator specified. Deserialization must NOT fail and use the discriminator type specified on the wire.
package complexgroup
import (
	"context"
	"net/http"
	"testing"
	"time"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/google/go-cmp/cmp"
)
func newPolymorphismClient() *PolymorphismClient {
	return NewPolymorphismClient(NewDefaultConnection(nil))
}
func TestPolymorphismGetComplicated(t *testing.T) {
	client := newPolymorphismClient()
	result, err := client.GetComplicated(context.Background(), nil)
	if err != nil {
		t.Fatal(err)
	}
	salmon, ok := result.SalmonClassification.(*SmartSalmon)
	if !ok {
		t.Fatal("fish wasn't a smart salmon")
	}
	goblinBday := time.Date(2015, time.August, 8, 0, 0, 0, 0, time.UTC)
	sawBday := time.Date(1900, time.January, 5, 1, 0, 0, 0, time.UTC)
	sharkBday := time.Date(2012, time.January, 5, 1, 0, 0, 0, time.UTC)
	expectedFish := Fish{
		Fishtype: to.StringPtr("smart_salmon"),
		Length:   to.Float32Ptr(1),
		Siblings: []FishClassification{
			&Shark{
				Fish: Fish{
					Fishtype: to.StringPtr("shark"),
					Length:   to.Float32Ptr(20),
					Species:  to.StringPtr("predator")},
				Age:      to.Int32Ptr(6),
				Birthday: &sharkBday,
			},
			&Sawshark{
				Shark: Shark{
					Fish: Fish{
						Fishtype: to.StringPtr("sawshark"),
						Length:   to.Float32Ptr(10),
						Species:  to.StringPtr("dangerous"),
					},
					Age:      to.Int32Ptr(105),
					Birthday: &sawBday,
				},
				Picture: []byte{255, 255, 255, 255, 254},
			},
			&Goblinshark{
				Shark: Shark{
					Fish: Fish{
						Fishtype: to.StringPtr("goblin"),
						Length:   to.Float32Ptr(30),
						Species:  to.StringPtr("scary"),
					},
					Age:      to.Int32Ptr(1),
					Birthday: &goblinBday,
				},
				Color:   GoblinSharkColor("pinkish-gray").ToPtr(),
				Jawsize: to.Int32Ptr(5),
			},
		},
		Species: to.StringPtr("king"),
	}
	expectedSalmon := Salmon{
		Fish:     expectedFish,
		Iswild:   to.BoolPtr(true),
		Location: to.StringPtr("alaska"),
	}
	if r := cmp.Diff(salmon, &SmartSalmon{
		Salmon: expectedSalmon,
		AdditionalProperties: map[string]interface{}{
			"additionalProperty1": float64(1),
			"additionalProperty2": false,
			"additionalProperty3": "hello",
			"additionalProperty4": map[string]interface{}{
				"a": float64(1),
				"b": float64(2),
			},
			"additionalProperty5": []interface{}{
				float64(1), float64(3),
			},
		},
	}); r != "" {
		t.Fatal(r)
	}
	if r := cmp.Diff(result.SalmonClassification.GetSalmon(), &expectedSalmon); r != "" {
		t.Fatal(r)
	}
	if r := cmp.Diff(result.SalmonClassification.GetFish(), &expectedFish); r != "" {
		t.Fatal(r)
	}
}