// 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_ElasticPoolPerDatabaseSettings_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 ElasticPoolPerDatabaseSettings_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForElasticPoolPerDatabaseSettings_STATUS, ElasticPoolPerDatabaseSettings_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ElasticPoolPerDatabaseSettings_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 ElasticPoolPerDatabaseSettings_STATUS instances for property testing - lazily instantiated by
// ElasticPoolPerDatabaseSettings_STATUSGenerator()
var elasticPoolPerDatabaseSettings_STATUSGenerator gopter.Gen

// ElasticPoolPerDatabaseSettings_STATUSGenerator returns a generator of ElasticPoolPerDatabaseSettings_STATUS instances for property testing.
func ElasticPoolPerDatabaseSettings_STATUSGenerator() gopter.Gen {
	if elasticPoolPerDatabaseSettings_STATUSGenerator != nil {
		return elasticPoolPerDatabaseSettings_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForElasticPoolPerDatabaseSettings_STATUS(generators)
	elasticPoolPerDatabaseSettings_STATUSGenerator = gen.Struct(reflect.TypeOf(ElasticPoolPerDatabaseSettings_STATUS{}), generators)

	return elasticPoolPerDatabaseSettings_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForElasticPoolPerDatabaseSettings_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForElasticPoolPerDatabaseSettings_STATUS(gens map[string]gopter.Gen) {
	gens["MaxCapacity"] = gen.PtrOf(gen.Float64())
	gens["MinCapacity"] = gen.PtrOf(gen.Float64())
}

func Test_ElasticPoolProperties_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 ElasticPoolProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForElasticPoolProperties_STATUS, ElasticPoolProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ElasticPoolProperties_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 ElasticPoolProperties_STATUS instances for property testing - lazily instantiated by
// ElasticPoolProperties_STATUSGenerator()
var elasticPoolProperties_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForElasticPoolProperties_STATUS(generators)
	elasticPoolProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(ElasticPoolProperties_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForElasticPoolProperties_STATUS(generators)
	AddRelatedPropertyGeneratorsForElasticPoolProperties_STATUS(generators)
	elasticPoolProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(ElasticPoolProperties_STATUS{}), generators)

	return elasticPoolProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForElasticPoolProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForElasticPoolProperties_STATUS(gens map[string]gopter.Gen) {
	gens["CreationDate"] = gen.PtrOf(gen.AlphaString())
	gens["HighAvailabilityReplicaCount"] = gen.PtrOf(gen.Int())
	gens["LicenseType"] = gen.PtrOf(gen.OneConstOf(ElasticPoolProperties_LicenseType_STATUS_BasePrice, ElasticPoolProperties_LicenseType_STATUS_LicenseIncluded))
	gens["MaintenanceConfigurationId"] = gen.PtrOf(gen.AlphaString())
	gens["MaxSizeBytes"] = gen.PtrOf(gen.Int())
	gens["MinCapacity"] = gen.PtrOf(gen.Float64())
	gens["State"] = gen.PtrOf(gen.OneConstOf(ElasticPoolProperties_State_STATUS_Creating, ElasticPoolProperties_State_STATUS_Disabled, ElasticPoolProperties_State_STATUS_Ready))
	gens["ZoneRedundant"] = gen.PtrOf(gen.Bool())
}

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

func Test_ServersElasticPool_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 ServersElasticPool_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersElasticPool_STATUS, ServersElasticPool_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersElasticPool_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 ServersElasticPool_STATUS instances for property testing - lazily instantiated by
// ServersElasticPool_STATUSGenerator()
var serversElasticPool_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersElasticPool_STATUS(generators)
	serversElasticPool_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersElasticPool_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersElasticPool_STATUS(generators)
	AddRelatedPropertyGeneratorsForServersElasticPool_STATUS(generators)
	serversElasticPool_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersElasticPool_STATUS{}), generators)

	return serversElasticPool_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForServersElasticPool_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForServersElasticPool_STATUS(gens map[string]gopter.Gen) {
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Kind"] = 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())
}

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