// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package arm

import (
	"encoding/json"
	"github.com/google/go-cmp/cmp"
	"github.com/google/go-cmp/cmp/cmpopts"
	"github.com/kr/pretty"
	"github.com/kylelemons/godebug/diff"
	"github.com/leanovate/gopter"
	"github.com/leanovate/gopter/gen"
	"github.com/leanovate/gopter/prop"
	"os"
	"reflect"
	"testing"
)

func Test_NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded, NatGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded runs a test to see if a specific instance of NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded round trips to JSON and back losslessly
func RunJSONSerializationTestForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded(subject NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded instances for property testing - lazily instantiated
// by NatGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator()
var natGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator gopter.Gen

// NatGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator returns a generator of NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded instances for property testing.
func NatGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator() gopter.Gen {
	if natGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator != nil {
		return natGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded(generators)
	natGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator = gen.Struct(reflect.TypeOf(NatGatewaySpec_PublicIPPrefix_SubResourceEmbedded{}), generators)

	return natGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator
}

// AddIndependentPropertyGeneratorsForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForNatGatewaySpec_PublicIPPrefix_SubResourceEmbedded(gens map[string]gopter.Gen) {
	gens["Id"] = gen.PtrOf(gen.AlphaString())
}

func Test_PublicIPPrefixPropertiesFormat_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of PublicIPPrefixPropertiesFormat via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPublicIPPrefixPropertiesFormat, PublicIPPrefixPropertiesFormatGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPublicIPPrefixPropertiesFormat runs a test to see if a specific instance of PublicIPPrefixPropertiesFormat round trips to JSON and back losslessly
func RunJSONSerializationTestForPublicIPPrefixPropertiesFormat(subject PublicIPPrefixPropertiesFormat) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual PublicIPPrefixPropertiesFormat
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of PublicIPPrefixPropertiesFormat instances for property testing - lazily instantiated by
// PublicIPPrefixPropertiesFormatGenerator()
var publicIPPrefixPropertiesFormatGenerator gopter.Gen

// PublicIPPrefixPropertiesFormatGenerator returns a generator of PublicIPPrefixPropertiesFormat instances for property testing.
// We first initialize publicIPPrefixPropertiesFormatGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func PublicIPPrefixPropertiesFormatGenerator() gopter.Gen {
	if publicIPPrefixPropertiesFormatGenerator != nil {
		return publicIPPrefixPropertiesFormatGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPublicIPPrefixPropertiesFormat(generators)
	publicIPPrefixPropertiesFormatGenerator = gen.Struct(reflect.TypeOf(PublicIPPrefixPropertiesFormat{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPublicIPPrefixPropertiesFormat(generators)
	AddRelatedPropertyGeneratorsForPublicIPPrefixPropertiesFormat(generators)
	publicIPPrefixPropertiesFormatGenerator = gen.Struct(reflect.TypeOf(PublicIPPrefixPropertiesFormat{}), generators)

	return publicIPPrefixPropertiesFormatGenerator
}

// AddIndependentPropertyGeneratorsForPublicIPPrefixPropertiesFormat is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPublicIPPrefixPropertiesFormat(gens map[string]gopter.Gen) {
	gens["PrefixLength"] = gen.PtrOf(gen.Int())
	gens["PublicIPAddressVersion"] = gen.PtrOf(gen.OneConstOf(IPVersion_IPv4, IPVersion_IPv6))
}

// AddRelatedPropertyGeneratorsForPublicIPPrefixPropertiesFormat is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForPublicIPPrefixPropertiesFormat(gens map[string]gopter.Gen) {
	gens["CustomIPPrefix"] = gen.PtrOf(SubResourceGenerator())
	gens["IpTags"] = gen.SliceOf(IpTagGenerator())
	gens["NatGateway"] = gen.PtrOf(NatGatewaySpec_PublicIPPrefix_SubResourceEmbeddedGenerator())
}

func Test_PublicIPPrefixSku_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of PublicIPPrefixSku via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPublicIPPrefixSku, PublicIPPrefixSkuGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPublicIPPrefixSku runs a test to see if a specific instance of PublicIPPrefixSku round trips to JSON and back losslessly
func RunJSONSerializationTestForPublicIPPrefixSku(subject PublicIPPrefixSku) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual PublicIPPrefixSku
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of PublicIPPrefixSku instances for property testing - lazily instantiated by PublicIPPrefixSkuGenerator()
var publicIPPrefixSkuGenerator gopter.Gen

// PublicIPPrefixSkuGenerator returns a generator of PublicIPPrefixSku instances for property testing.
func PublicIPPrefixSkuGenerator() gopter.Gen {
	if publicIPPrefixSkuGenerator != nil {
		return publicIPPrefixSkuGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPublicIPPrefixSku(generators)
	publicIPPrefixSkuGenerator = gen.Struct(reflect.TypeOf(PublicIPPrefixSku{}), generators)

	return publicIPPrefixSkuGenerator
}

// AddIndependentPropertyGeneratorsForPublicIPPrefixSku is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPublicIPPrefixSku(gens map[string]gopter.Gen) {
	gens["Name"] = gen.PtrOf(gen.OneConstOf(PublicIPPrefixSku_Name_Standard))
	gens["Tier"] = gen.PtrOf(gen.OneConstOf(PublicIPPrefixSku_Tier_Global, PublicIPPrefixSku_Tier_Regional))
}

func Test_PublicIPPrefix_Spec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 80
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of PublicIPPrefix_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPublicIPPrefix_Spec, PublicIPPrefix_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

// RunJSONSerializationTestForPublicIPPrefix_Spec runs a test to see if a specific instance of PublicIPPrefix_Spec round trips to JSON and back losslessly
func RunJSONSerializationTestForPublicIPPrefix_Spec(subject PublicIPPrefix_Spec) string {
	// Serialize to JSON
	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	// Deserialize back into memory
	var actual PublicIPPrefix_Spec
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	// Check for outcome
	match := cmp.Equal(subject, actual, cmpopts.EquateEmpty())
	if !match {
		actualFmt := pretty.Sprint(actual)
		subjectFmt := pretty.Sprint(subject)
		result := diff.Diff(subjectFmt, actualFmt)
		return result
	}

	return ""
}

// Generator of PublicIPPrefix_Spec instances for property testing - lazily instantiated by
// PublicIPPrefix_SpecGenerator()
var publicIPPrefix_SpecGenerator gopter.Gen

// PublicIPPrefix_SpecGenerator returns a generator of PublicIPPrefix_Spec instances for property testing.
// We first initialize publicIPPrefix_SpecGenerator with a simplified generator based on the
// fields with primitive types then replacing it with a more complex one that also handles complex fields
// to ensure any cycles in the object graph properly terminate.
func PublicIPPrefix_SpecGenerator() gopter.Gen {
	if publicIPPrefix_SpecGenerator != nil {
		return publicIPPrefix_SpecGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPublicIPPrefix_Spec(generators)
	publicIPPrefix_SpecGenerator = gen.Struct(reflect.TypeOf(PublicIPPrefix_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPublicIPPrefix_Spec(generators)
	AddRelatedPropertyGeneratorsForPublicIPPrefix_Spec(generators)
	publicIPPrefix_SpecGenerator = gen.Struct(reflect.TypeOf(PublicIPPrefix_Spec{}), generators)

	return publicIPPrefix_SpecGenerator
}

// AddIndependentPropertyGeneratorsForPublicIPPrefix_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPublicIPPrefix_Spec(gens map[string]gopter.Gen) {
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.AlphaString()
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["Zones"] = gen.SliceOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForPublicIPPrefix_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForPublicIPPrefix_Spec(gens map[string]gopter.Gen) {
	gens["ExtendedLocation"] = gen.PtrOf(ExtendedLocationGenerator())
	gens["Properties"] = gen.PtrOf(PublicIPPrefixPropertiesFormatGenerator())
	gens["Sku"] = gen.PtrOf(PublicIPPrefixSkuGenerator())
}
