// 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_AdvancedThreatProtectionProperties_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 AdvancedThreatProtectionProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAdvancedThreatProtectionProperties_STATUS, AdvancedThreatProtectionProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual AdvancedThreatProtectionProperties_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 AdvancedThreatProtectionProperties_STATUS instances for property testing - lazily instantiated by
// AdvancedThreatProtectionProperties_STATUSGenerator()
var advancedThreatProtectionProperties_STATUSGenerator gopter.Gen

// AdvancedThreatProtectionProperties_STATUSGenerator returns a generator of AdvancedThreatProtectionProperties_STATUS instances for property testing.
func AdvancedThreatProtectionProperties_STATUSGenerator() gopter.Gen {
	if advancedThreatProtectionProperties_STATUSGenerator != nil {
		return advancedThreatProtectionProperties_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAdvancedThreatProtectionProperties_STATUS(generators)
	advancedThreatProtectionProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(AdvancedThreatProtectionProperties_STATUS{}), generators)

	return advancedThreatProtectionProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForAdvancedThreatProtectionProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForAdvancedThreatProtectionProperties_STATUS(gens map[string]gopter.Gen) {
	gens["CreationTime"] = gen.PtrOf(gen.AlphaString())
	gens["State"] = gen.PtrOf(gen.OneConstOf(AdvancedThreatProtectionProperties_State_STATUS_Disabled, AdvancedThreatProtectionProperties_State_STATUS_Enabled, AdvancedThreatProtectionProperties_State_STATUS_New))
}

func Test_ServersAdvancedThreatProtectionSetting_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 ServersAdvancedThreatProtectionSetting_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersAdvancedThreatProtectionSetting_STATUS, ServersAdvancedThreatProtectionSetting_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersAdvancedThreatProtectionSetting_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 ServersAdvancedThreatProtectionSetting_STATUS instances for property testing - lazily instantiated by
// ServersAdvancedThreatProtectionSetting_STATUSGenerator()
var serversAdvancedThreatProtectionSetting_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersAdvancedThreatProtectionSetting_STATUS(generators)
	serversAdvancedThreatProtectionSetting_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersAdvancedThreatProtectionSetting_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersAdvancedThreatProtectionSetting_STATUS(generators)
	AddRelatedPropertyGeneratorsForServersAdvancedThreatProtectionSetting_STATUS(generators)
	serversAdvancedThreatProtectionSetting_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersAdvancedThreatProtectionSetting_STATUS{}), generators)

	return serversAdvancedThreatProtectionSetting_STATUSGenerator
}

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

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

func Test_SystemData_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 SystemData_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSystemData_STATUS, SystemData_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual SystemData_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 SystemData_STATUS instances for property testing - lazily instantiated by SystemData_STATUSGenerator()
var systemData_STATUSGenerator gopter.Gen

// SystemData_STATUSGenerator returns a generator of SystemData_STATUS instances for property testing.
func SystemData_STATUSGenerator() gopter.Gen {
	if systemData_STATUSGenerator != nil {
		return systemData_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSystemData_STATUS(generators)
	systemData_STATUSGenerator = gen.Struct(reflect.TypeOf(SystemData_STATUS{}), generators)

	return systemData_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForSystemData_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSystemData_STATUS(gens map[string]gopter.Gen) {
	gens["CreatedAt"] = gen.PtrOf(gen.AlphaString())
	gens["CreatedBy"] = gen.PtrOf(gen.AlphaString())
	gens["CreatedByType"] = gen.PtrOf(gen.OneConstOf(
		SystemData_CreatedByType_STATUS_Application,
		SystemData_CreatedByType_STATUS_Key,
		SystemData_CreatedByType_STATUS_ManagedIdentity,
		SystemData_CreatedByType_STATUS_User))
	gens["LastModifiedAt"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedBy"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedByType"] = gen.PtrOf(gen.OneConstOf(
		SystemData_LastModifiedByType_STATUS_Application,
		SystemData_LastModifiedByType_STATUS_Key,
		SystemData_LastModifiedByType_STATUS_ManagedIdentity,
		SystemData_LastModifiedByType_STATUS_User))
}
