// 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_DnsConfig_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 DnsConfig via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsConfig, DnsConfigGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsConfig
	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 DnsConfig instances for property testing - lazily instantiated by DnsConfigGenerator()
var dnsConfigGenerator gopter.Gen

// DnsConfigGenerator returns a generator of DnsConfig instances for property testing.
func DnsConfigGenerator() gopter.Gen {
	if dnsConfigGenerator != nil {
		return dnsConfigGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsConfig(generators)
	dnsConfigGenerator = gen.Struct(reflect.TypeOf(DnsConfig{}), generators)

	return dnsConfigGenerator
}

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

func Test_MonitorConfig_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 MonitorConfig via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMonitorConfig, MonitorConfigGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual MonitorConfig
	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 MonitorConfig instances for property testing - lazily instantiated by MonitorConfigGenerator()
var monitorConfigGenerator gopter.Gen

// MonitorConfigGenerator returns a generator of MonitorConfig instances for property testing.
// We first initialize monitorConfigGenerator 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 MonitorConfigGenerator() gopter.Gen {
	if monitorConfigGenerator != nil {
		return monitorConfigGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMonitorConfig(generators)
	monitorConfigGenerator = gen.Struct(reflect.TypeOf(MonitorConfig{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMonitorConfig(generators)
	AddRelatedPropertyGeneratorsForMonitorConfig(generators)
	monitorConfigGenerator = gen.Struct(reflect.TypeOf(MonitorConfig{}), generators)

	return monitorConfigGenerator
}

// AddIndependentPropertyGeneratorsForMonitorConfig is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForMonitorConfig(gens map[string]gopter.Gen) {
	gens["IntervalInSeconds"] = gen.PtrOf(gen.Int())
	gens["Path"] = gen.PtrOf(gen.AlphaString())
	gens["Port"] = gen.PtrOf(gen.Int())
	gens["ProfileMonitorStatus"] = gen.PtrOf(gen.OneConstOf(
		MonitorConfig_ProfileMonitorStatus_CheckingEndpoints,
		MonitorConfig_ProfileMonitorStatus_Degraded,
		MonitorConfig_ProfileMonitorStatus_Disabled,
		MonitorConfig_ProfileMonitorStatus_Inactive,
		MonitorConfig_ProfileMonitorStatus_Online))
	gens["Protocol"] = gen.PtrOf(gen.OneConstOf(MonitorConfig_Protocol_HTTP, MonitorConfig_Protocol_HTTPS, MonitorConfig_Protocol_TCP))
	gens["TimeoutInSeconds"] = gen.PtrOf(gen.Int())
	gens["ToleratedNumberOfFailures"] = gen.PtrOf(gen.Int())
}

// AddRelatedPropertyGeneratorsForMonitorConfig is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForMonitorConfig(gens map[string]gopter.Gen) {
	gens["CustomHeaders"] = gen.SliceOf(MonitorConfig_CustomHeadersGenerator())
	gens["ExpectedStatusCodeRanges"] = gen.SliceOf(MonitorConfig_ExpectedStatusCodeRangesGenerator())
}

func Test_MonitorConfig_CustomHeaders_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 MonitorConfig_CustomHeaders via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMonitorConfig_CustomHeaders, MonitorConfig_CustomHeadersGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual MonitorConfig_CustomHeaders
	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 MonitorConfig_CustomHeaders instances for property testing - lazily instantiated by
// MonitorConfig_CustomHeadersGenerator()
var monitorConfig_CustomHeadersGenerator gopter.Gen

// MonitorConfig_CustomHeadersGenerator returns a generator of MonitorConfig_CustomHeaders instances for property testing.
func MonitorConfig_CustomHeadersGenerator() gopter.Gen {
	if monitorConfig_CustomHeadersGenerator != nil {
		return monitorConfig_CustomHeadersGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMonitorConfig_CustomHeaders(generators)
	monitorConfig_CustomHeadersGenerator = gen.Struct(reflect.TypeOf(MonitorConfig_CustomHeaders{}), generators)

	return monitorConfig_CustomHeadersGenerator
}

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

func Test_MonitorConfig_ExpectedStatusCodeRanges_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 MonitorConfig_ExpectedStatusCodeRanges via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMonitorConfig_ExpectedStatusCodeRanges, MonitorConfig_ExpectedStatusCodeRangesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual MonitorConfig_ExpectedStatusCodeRanges
	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 MonitorConfig_ExpectedStatusCodeRanges instances for property testing - lazily instantiated by
// MonitorConfig_ExpectedStatusCodeRangesGenerator()
var monitorConfig_ExpectedStatusCodeRangesGenerator gopter.Gen

// MonitorConfig_ExpectedStatusCodeRangesGenerator returns a generator of MonitorConfig_ExpectedStatusCodeRanges instances for property testing.
func MonitorConfig_ExpectedStatusCodeRangesGenerator() gopter.Gen {
	if monitorConfig_ExpectedStatusCodeRangesGenerator != nil {
		return monitorConfig_ExpectedStatusCodeRangesGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForMonitorConfig_ExpectedStatusCodeRanges(generators)
	monitorConfig_ExpectedStatusCodeRangesGenerator = gen.Struct(reflect.TypeOf(MonitorConfig_ExpectedStatusCodeRanges{}), generators)

	return monitorConfig_ExpectedStatusCodeRangesGenerator
}

// AddIndependentPropertyGeneratorsForMonitorConfig_ExpectedStatusCodeRanges is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForMonitorConfig_ExpectedStatusCodeRanges(gens map[string]gopter.Gen) {
	gens["Max"] = gen.PtrOf(gen.Int())
	gens["Min"] = gen.PtrOf(gen.Int())
}

func Test_ProfileProperties_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 ProfileProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForProfileProperties, ProfilePropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ProfileProperties
	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 ProfileProperties instances for property testing - lazily instantiated by ProfilePropertiesGenerator()
var profilePropertiesGenerator gopter.Gen

// ProfilePropertiesGenerator returns a generator of ProfileProperties instances for property testing.
// We first initialize profilePropertiesGenerator 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 ProfilePropertiesGenerator() gopter.Gen {
	if profilePropertiesGenerator != nil {
		return profilePropertiesGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForProfileProperties(generators)
	profilePropertiesGenerator = gen.Struct(reflect.TypeOf(ProfileProperties{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForProfileProperties(generators)
	AddRelatedPropertyGeneratorsForProfileProperties(generators)
	profilePropertiesGenerator = gen.Struct(reflect.TypeOf(ProfileProperties{}), generators)

	return profilePropertiesGenerator
}

// AddIndependentPropertyGeneratorsForProfileProperties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForProfileProperties(gens map[string]gopter.Gen) {
	gens["AllowedEndpointRecordTypes"] = gen.SliceOf(gen.OneConstOf(
		AllowedEndpointRecordType_Any,
		AllowedEndpointRecordType_DomainName,
		AllowedEndpointRecordType_IPv4Address,
		AllowedEndpointRecordType_IPv6Address))
	gens["MaxReturn"] = gen.PtrOf(gen.Int())
	gens["ProfileStatus"] = gen.PtrOf(gen.OneConstOf(ProfileProperties_ProfileStatus_Disabled, ProfileProperties_ProfileStatus_Enabled))
	gens["TrafficRoutingMethod"] = gen.PtrOf(gen.OneConstOf(
		ProfileProperties_TrafficRoutingMethod_Geographic,
		ProfileProperties_TrafficRoutingMethod_MultiValue,
		ProfileProperties_TrafficRoutingMethod_Performance,
		ProfileProperties_TrafficRoutingMethod_Priority,
		ProfileProperties_TrafficRoutingMethod_Subnet,
		ProfileProperties_TrafficRoutingMethod_Weighted))
	gens["TrafficViewEnrollmentStatus"] = gen.PtrOf(gen.OneConstOf(ProfileProperties_TrafficViewEnrollmentStatus_Disabled, ProfileProperties_TrafficViewEnrollmentStatus_Enabled))
}

// AddRelatedPropertyGeneratorsForProfileProperties is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForProfileProperties(gens map[string]gopter.Gen) {
	gens["DnsConfig"] = gen.PtrOf(DnsConfigGenerator())
	gens["MonitorConfig"] = gen.PtrOf(MonitorConfigGenerator())
}

func Test_TrafficManagerProfile_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 TrafficManagerProfile_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForTrafficManagerProfile_Spec, TrafficManagerProfile_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual TrafficManagerProfile_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 TrafficManagerProfile_Spec instances for property testing - lazily instantiated by
// TrafficManagerProfile_SpecGenerator()
var trafficManagerProfile_SpecGenerator gopter.Gen

// TrafficManagerProfile_SpecGenerator returns a generator of TrafficManagerProfile_Spec instances for property testing.
// We first initialize trafficManagerProfile_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 TrafficManagerProfile_SpecGenerator() gopter.Gen {
	if trafficManagerProfile_SpecGenerator != nil {
		return trafficManagerProfile_SpecGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForTrafficManagerProfile_Spec(generators)
	trafficManagerProfile_SpecGenerator = gen.Struct(reflect.TypeOf(TrafficManagerProfile_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForTrafficManagerProfile_Spec(generators)
	AddRelatedPropertyGeneratorsForTrafficManagerProfile_Spec(generators)
	trafficManagerProfile_SpecGenerator = gen.Struct(reflect.TypeOf(TrafficManagerProfile_Spec{}), generators)

	return trafficManagerProfile_SpecGenerator
}

// AddIndependentPropertyGeneratorsForTrafficManagerProfile_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForTrafficManagerProfile_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["Type"] = gen.PtrOf(gen.AlphaString())
}

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