// 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_AFDEndpointProperties_STATUS_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 AFDEndpointProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAFDEndpointProperties_STATUS, AFDEndpointProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// AFDEndpointProperties_STATUSGenerator returns a generator of AFDEndpointProperties_STATUS instances for property testing.
func AFDEndpointProperties_STATUSGenerator() gopter.Gen {
	if afdEndpointProperties_STATUSGenerator != nil {
		return afdEndpointProperties_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAFDEndpointProperties_STATUS(generators)
	afdEndpointProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(AFDEndpointProperties_STATUS{}), generators)

	return afdEndpointProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForAFDEndpointProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForAFDEndpointProperties_STATUS(gens map[string]gopter.Gen) {
	gens["AutoGeneratedDomainNameLabelScope"] = gen.PtrOf(gen.OneConstOf(
		AutoGeneratedDomainNameLabelScope_STATUS_NoReuse,
		AutoGeneratedDomainNameLabelScope_STATUS_ResourceGroupReuse,
		AutoGeneratedDomainNameLabelScope_STATUS_SubscriptionReuse,
		AutoGeneratedDomainNameLabelScope_STATUS_TenantReuse))
	gens["DeploymentStatus"] = gen.PtrOf(gen.OneConstOf(
		AFDEndpointProperties_DeploymentStatus_STATUS_Failed,
		AFDEndpointProperties_DeploymentStatus_STATUS_InProgress,
		AFDEndpointProperties_DeploymentStatus_STATUS_NotStarted,
		AFDEndpointProperties_DeploymentStatus_STATUS_Succeeded))
	gens["EnabledState"] = gen.PtrOf(gen.OneConstOf(AFDEndpointProperties_EnabledState_STATUS_Disabled, AFDEndpointProperties_EnabledState_STATUS_Enabled))
	gens["HostName"] = gen.PtrOf(gen.AlphaString())
	gens["ProfileName"] = gen.PtrOf(gen.AlphaString())
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		AFDEndpointProperties_ProvisioningState_STATUS_Creating,
		AFDEndpointProperties_ProvisioningState_STATUS_Deleting,
		AFDEndpointProperties_ProvisioningState_STATUS_Failed,
		AFDEndpointProperties_ProvisioningState_STATUS_Succeeded,
		AFDEndpointProperties_ProvisioningState_STATUS_Updating))
}

func Test_AfdEndpoint_STATUS_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 AfdEndpoint_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAfdEndpoint_STATUS, AfdEndpoint_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAfdEndpoint_STATUS(generators)
	afdEndpoint_STATUSGenerator = gen.Struct(reflect.TypeOf(AfdEndpoint_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAfdEndpoint_STATUS(generators)
	AddRelatedPropertyGeneratorsForAfdEndpoint_STATUS(generators)
	afdEndpoint_STATUSGenerator = gen.Struct(reflect.TypeOf(AfdEndpoint_STATUS{}), generators)

	return afdEndpoint_STATUSGenerator
}

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

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