// 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_EndpointProperties_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 EndpointProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForEndpointProperties, EndpointPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEndpointProperties(generators)
	endpointPropertiesGenerator = gen.Struct(reflect.TypeOf(EndpointProperties{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEndpointProperties(generators)
	AddRelatedPropertyGeneratorsForEndpointProperties(generators)
	endpointPropertiesGenerator = gen.Struct(reflect.TypeOf(EndpointProperties{}), generators)

	return endpointPropertiesGenerator
}

// AddIndependentPropertyGeneratorsForEndpointProperties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForEndpointProperties(gens map[string]gopter.Gen) {
	gens["AlwaysServe"] = gen.PtrOf(gen.OneConstOf(EndpointProperties_AlwaysServe_Disabled, EndpointProperties_AlwaysServe_Enabled))
	gens["EndpointLocation"] = gen.PtrOf(gen.AlphaString())
	gens["EndpointMonitorStatus"] = gen.PtrOf(gen.OneConstOf(
		EndpointProperties_EndpointMonitorStatus_CheckingEndpoint,
		EndpointProperties_EndpointMonitorStatus_Degraded,
		EndpointProperties_EndpointMonitorStatus_Disabled,
		EndpointProperties_EndpointMonitorStatus_Inactive,
		EndpointProperties_EndpointMonitorStatus_Online,
		EndpointProperties_EndpointMonitorStatus_Stopped,
		EndpointProperties_EndpointMonitorStatus_Unmonitored))
	gens["EndpointStatus"] = gen.PtrOf(gen.OneConstOf(EndpointProperties_EndpointStatus_Disabled, EndpointProperties_EndpointStatus_Enabled))
	gens["GeoMapping"] = gen.SliceOf(gen.AlphaString())
	gens["MinChildEndpoints"] = gen.PtrOf(gen.Int())
	gens["MinChildEndpointsIPv4"] = gen.PtrOf(gen.Int())
	gens["MinChildEndpointsIPv6"] = gen.PtrOf(gen.Int())
	gens["Priority"] = gen.PtrOf(gen.Int())
	gens["Target"] = gen.PtrOf(gen.AlphaString())
	gens["TargetResourceId"] = gen.PtrOf(gen.AlphaString())
	gens["Weight"] = gen.PtrOf(gen.Int())
}

// AddRelatedPropertyGeneratorsForEndpointProperties is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForEndpointProperties(gens map[string]gopter.Gen) {
	gens["CustomHeaders"] = gen.SliceOf(EndpointProperties_CustomHeadersGenerator())
	gens["Subnets"] = gen.SliceOf(EndpointProperties_SubnetsGenerator())
}

func Test_EndpointProperties_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 EndpointProperties_CustomHeaders via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForEndpointProperties_CustomHeaders, EndpointProperties_CustomHeadersGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual EndpointProperties_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 EndpointProperties_CustomHeaders instances for property testing - lazily instantiated by
// EndpointProperties_CustomHeadersGenerator()
var endpointProperties_CustomHeadersGenerator gopter.Gen

// EndpointProperties_CustomHeadersGenerator returns a generator of EndpointProperties_CustomHeaders instances for property testing.
func EndpointProperties_CustomHeadersGenerator() gopter.Gen {
	if endpointProperties_CustomHeadersGenerator != nil {
		return endpointProperties_CustomHeadersGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEndpointProperties_CustomHeaders(generators)
	endpointProperties_CustomHeadersGenerator = gen.Struct(reflect.TypeOf(EndpointProperties_CustomHeaders{}), generators)

	return endpointProperties_CustomHeadersGenerator
}

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

func Test_EndpointProperties_Subnets_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 EndpointProperties_Subnets via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForEndpointProperties_Subnets, EndpointProperties_SubnetsGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// EndpointProperties_SubnetsGenerator returns a generator of EndpointProperties_Subnets instances for property testing.
func EndpointProperties_SubnetsGenerator() gopter.Gen {
	if endpointProperties_SubnetsGenerator != nil {
		return endpointProperties_SubnetsGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEndpointProperties_Subnets(generators)
	endpointProperties_SubnetsGenerator = gen.Struct(reflect.TypeOf(EndpointProperties_Subnets{}), generators)

	return endpointProperties_SubnetsGenerator
}

// AddIndependentPropertyGeneratorsForEndpointProperties_Subnets is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForEndpointProperties_Subnets(gens map[string]gopter.Gen) {
	gens["First"] = gen.PtrOf(gen.AlphaString())
	gens["Last"] = gen.PtrOf(gen.AlphaString())
	gens["Scope"] = gen.PtrOf(gen.Int())
}

func Test_TrafficManagerProfilesAzureEndpoint_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 TrafficManagerProfilesAzureEndpoint_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForTrafficManagerProfilesAzureEndpoint_Spec, TrafficManagerProfilesAzureEndpoint_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual TrafficManagerProfilesAzureEndpoint_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 TrafficManagerProfilesAzureEndpoint_Spec instances for property testing - lazily instantiated by
// TrafficManagerProfilesAzureEndpoint_SpecGenerator()
var trafficManagerProfilesAzureEndpoint_SpecGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForTrafficManagerProfilesAzureEndpoint_Spec(generators)
	trafficManagerProfilesAzureEndpoint_SpecGenerator = gen.Struct(reflect.TypeOf(TrafficManagerProfilesAzureEndpoint_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForTrafficManagerProfilesAzureEndpoint_Spec(generators)
	AddRelatedPropertyGeneratorsForTrafficManagerProfilesAzureEndpoint_Spec(generators)
	trafficManagerProfilesAzureEndpoint_SpecGenerator = gen.Struct(reflect.TypeOf(TrafficManagerProfilesAzureEndpoint_Spec{}), generators)

	return trafficManagerProfilesAzureEndpoint_SpecGenerator
}

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

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