// 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_RegistryReplication_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 RegistryReplication_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRegistryReplication_STATUS, RegistryReplication_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RegistryReplication_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 RegistryReplication_STATUS instances for property testing - lazily instantiated by
// RegistryReplication_STATUSGenerator()
var registryReplication_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRegistryReplication_STATUS(generators)
	registryReplication_STATUSGenerator = gen.Struct(reflect.TypeOf(RegistryReplication_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRegistryReplication_STATUS(generators)
	AddRelatedPropertyGeneratorsForRegistryReplication_STATUS(generators)
	registryReplication_STATUSGenerator = gen.Struct(reflect.TypeOf(RegistryReplication_STATUS{}), generators)

	return registryReplication_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForRegistryReplication_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRegistryReplication_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())
}

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

func Test_ReplicationProperties_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 ReplicationProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForReplicationProperties_STATUS, ReplicationProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ReplicationProperties_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 ReplicationProperties_STATUS instances for property testing - lazily instantiated by
// ReplicationProperties_STATUSGenerator()
var replicationProperties_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForReplicationProperties_STATUS(generators)
	replicationProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(ReplicationProperties_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForReplicationProperties_STATUS(generators)
	AddRelatedPropertyGeneratorsForReplicationProperties_STATUS(generators)
	replicationProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(ReplicationProperties_STATUS{}), generators)

	return replicationProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForReplicationProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForReplicationProperties_STATUS(gens map[string]gopter.Gen) {
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		ReplicationProperties_ProvisioningState_STATUS_Canceled,
		ReplicationProperties_ProvisioningState_STATUS_Creating,
		ReplicationProperties_ProvisioningState_STATUS_Deleting,
		ReplicationProperties_ProvisioningState_STATUS_Failed,
		ReplicationProperties_ProvisioningState_STATUS_Succeeded,
		ReplicationProperties_ProvisioningState_STATUS_Updating))
	gens["RegionEndpointEnabled"] = gen.PtrOf(gen.Bool())
	gens["ZoneRedundancy"] = gen.PtrOf(gen.OneConstOf(ReplicationProperties_ZoneRedundancy_STATUS_Disabled, ReplicationProperties_ZoneRedundancy_STATUS_Enabled))
}

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

func Test_Status_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 Status_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStatus_STATUS, Status_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Status_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 Status_STATUS instances for property testing - lazily instantiated by Status_STATUSGenerator()
var status_STATUSGenerator gopter.Gen

// Status_STATUSGenerator returns a generator of Status_STATUS instances for property testing.
func Status_STATUSGenerator() gopter.Gen {
	if status_STATUSGenerator != nil {
		return status_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStatus_STATUS(generators)
	status_STATUSGenerator = gen.Struct(reflect.TypeOf(Status_STATUS{}), generators)

	return status_STATUSGenerator
}

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

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))
}
