// 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_DatabaseProperties_GeoReplication_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 DatabaseProperties_GeoReplication_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDatabaseProperties_GeoReplication_STATUS, DatabaseProperties_GeoReplication_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DatabaseProperties_GeoReplication_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 DatabaseProperties_GeoReplication_STATUS instances for property testing - lazily instantiated by
// DatabaseProperties_GeoReplication_STATUSGenerator()
var databaseProperties_GeoReplication_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDatabaseProperties_GeoReplication_STATUS(generators)
	databaseProperties_GeoReplication_STATUSGenerator = gen.Struct(reflect.TypeOf(DatabaseProperties_GeoReplication_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDatabaseProperties_GeoReplication_STATUS(generators)
	AddRelatedPropertyGeneratorsForDatabaseProperties_GeoReplication_STATUS(generators)
	databaseProperties_GeoReplication_STATUSGenerator = gen.Struct(reflect.TypeOf(DatabaseProperties_GeoReplication_STATUS{}), generators)

	return databaseProperties_GeoReplication_STATUSGenerator
}

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

// AddRelatedPropertyGeneratorsForDatabaseProperties_GeoReplication_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDatabaseProperties_GeoReplication_STATUS(gens map[string]gopter.Gen) {
	gens["LinkedDatabases"] = gen.SliceOf(LinkedDatabase_STATUSGenerator())
}

func Test_DatabaseProperties_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 DatabaseProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDatabaseProperties_STATUS, DatabaseProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DatabaseProperties_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 DatabaseProperties_STATUS instances for property testing - lazily instantiated by
// DatabaseProperties_STATUSGenerator()
var databaseProperties_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDatabaseProperties_STATUS(generators)
	databaseProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(DatabaseProperties_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDatabaseProperties_STATUS(generators)
	AddRelatedPropertyGeneratorsForDatabaseProperties_STATUS(generators)
	databaseProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(DatabaseProperties_STATUS{}), generators)

	return databaseProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForDatabaseProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDatabaseProperties_STATUS(gens map[string]gopter.Gen) {
	gens["ClientProtocol"] = gen.PtrOf(gen.OneConstOf(DatabaseProperties_ClientProtocol_STATUS_Encrypted, DatabaseProperties_ClientProtocol_STATUS_Plaintext))
	gens["ClusteringPolicy"] = gen.PtrOf(gen.OneConstOf(DatabaseProperties_ClusteringPolicy_STATUS_EnterpriseCluster, DatabaseProperties_ClusteringPolicy_STATUS_OSSCluster))
	gens["EvictionPolicy"] = gen.PtrOf(gen.OneConstOf(
		DatabaseProperties_EvictionPolicy_STATUS_AllKeysLFU,
		DatabaseProperties_EvictionPolicy_STATUS_AllKeysLRU,
		DatabaseProperties_EvictionPolicy_STATUS_AllKeysRandom,
		DatabaseProperties_EvictionPolicy_STATUS_NoEviction,
		DatabaseProperties_EvictionPolicy_STATUS_VolatileLFU,
		DatabaseProperties_EvictionPolicy_STATUS_VolatileLRU,
		DatabaseProperties_EvictionPolicy_STATUS_VolatileRandom,
		DatabaseProperties_EvictionPolicy_STATUS_VolatileTTL))
	gens["Port"] = gen.PtrOf(gen.Int())
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		ProvisioningState_STATUS_Canceled,
		ProvisioningState_STATUS_Creating,
		ProvisioningState_STATUS_Deleting,
		ProvisioningState_STATUS_Failed,
		ProvisioningState_STATUS_Succeeded,
		ProvisioningState_STATUS_Updating))
	gens["ResourceState"] = gen.PtrOf(gen.OneConstOf(
		ResourceState_STATUS_CreateFailed,
		ResourceState_STATUS_Creating,
		ResourceState_STATUS_DeleteFailed,
		ResourceState_STATUS_Deleting,
		ResourceState_STATUS_DisableFailed,
		ResourceState_STATUS_Disabled,
		ResourceState_STATUS_Disabling,
		ResourceState_STATUS_EnableFailed,
		ResourceState_STATUS_Enabling,
		ResourceState_STATUS_Running,
		ResourceState_STATUS_UpdateFailed,
		ResourceState_STATUS_Updating))
}

// AddRelatedPropertyGeneratorsForDatabaseProperties_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDatabaseProperties_STATUS(gens map[string]gopter.Gen) {
	gens["GeoReplication"] = gen.PtrOf(DatabaseProperties_GeoReplication_STATUSGenerator())
	gens["Modules"] = gen.SliceOf(Module_STATUSGenerator())
	gens["Persistence"] = gen.PtrOf(Persistence_STATUSGenerator())
}

func Test_LinkedDatabase_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 LinkedDatabase_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForLinkedDatabase_STATUS, LinkedDatabase_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual LinkedDatabase_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 LinkedDatabase_STATUS instances for property testing - lazily instantiated by
// LinkedDatabase_STATUSGenerator()
var linkedDatabase_STATUSGenerator gopter.Gen

// LinkedDatabase_STATUSGenerator returns a generator of LinkedDatabase_STATUS instances for property testing.
func LinkedDatabase_STATUSGenerator() gopter.Gen {
	if linkedDatabase_STATUSGenerator != nil {
		return linkedDatabase_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForLinkedDatabase_STATUS(generators)
	linkedDatabase_STATUSGenerator = gen.Struct(reflect.TypeOf(LinkedDatabase_STATUS{}), generators)

	return linkedDatabase_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForLinkedDatabase_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForLinkedDatabase_STATUS(gens map[string]gopter.Gen) {
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["State"] = gen.PtrOf(gen.OneConstOf(
		LinkedDatabase_State_STATUS_LinkFailed,
		LinkedDatabase_State_STATUS_Linked,
		LinkedDatabase_State_STATUS_Linking,
		LinkedDatabase_State_STATUS_UnlinkFailed,
		LinkedDatabase_State_STATUS_Unlinking))
}

func Test_Module_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 Module_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForModule_STATUS, Module_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Module_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 Module_STATUS instances for property testing - lazily instantiated by Module_STATUSGenerator()
var module_STATUSGenerator gopter.Gen

// Module_STATUSGenerator returns a generator of Module_STATUS instances for property testing.
func Module_STATUSGenerator() gopter.Gen {
	if module_STATUSGenerator != nil {
		return module_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForModule_STATUS(generators)
	module_STATUSGenerator = gen.Struct(reflect.TypeOf(Module_STATUS{}), generators)

	return module_STATUSGenerator
}

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

func Test_Persistence_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 Persistence_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForPersistence_STATUS, Persistence_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Persistence_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 Persistence_STATUS instances for property testing - lazily instantiated by Persistence_STATUSGenerator()
var persistence_STATUSGenerator gopter.Gen

// Persistence_STATUSGenerator returns a generator of Persistence_STATUS instances for property testing.
func Persistence_STATUSGenerator() gopter.Gen {
	if persistence_STATUSGenerator != nil {
		return persistence_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPersistence_STATUS(generators)
	persistence_STATUSGenerator = gen.Struct(reflect.TypeOf(Persistence_STATUS{}), generators)

	return persistence_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForPersistence_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPersistence_STATUS(gens map[string]gopter.Gen) {
	gens["AofEnabled"] = gen.PtrOf(gen.Bool())
	gens["AofFrequency"] = gen.PtrOf(gen.OneConstOf(Persistence_AofFrequency_STATUS_1S, Persistence_AofFrequency_STATUS_Always))
	gens["RdbEnabled"] = gen.PtrOf(gen.Bool())
	gens["RdbFrequency"] = gen.PtrOf(gen.OneConstOf(Persistence_RdbFrequency_STATUS_12H, Persistence_RdbFrequency_STATUS_1H, Persistence_RdbFrequency_STATUS_6H))
}

func Test_RedisEnterpriseDatabase_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 RedisEnterpriseDatabase_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRedisEnterpriseDatabase_STATUS, RedisEnterpriseDatabase_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RedisEnterpriseDatabase_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 RedisEnterpriseDatabase_STATUS instances for property testing - lazily instantiated by
// RedisEnterpriseDatabase_STATUSGenerator()
var redisEnterpriseDatabase_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRedisEnterpriseDatabase_STATUS(generators)
	redisEnterpriseDatabase_STATUSGenerator = gen.Struct(reflect.TypeOf(RedisEnterpriseDatabase_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRedisEnterpriseDatabase_STATUS(generators)
	AddRelatedPropertyGeneratorsForRedisEnterpriseDatabase_STATUS(generators)
	redisEnterpriseDatabase_STATUSGenerator = gen.Struct(reflect.TypeOf(RedisEnterpriseDatabase_STATUS{}), generators)

	return redisEnterpriseDatabase_STATUSGenerator
}

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

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