// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1api20211101

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/sql/v1api20211101/storage"
	"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_ServersDatabasesTransparentDataEncryption_WhenConvertedToHub_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	parameters.MinSuccessfulTests = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ServersDatabasesTransparentDataEncryption to hub returns original",
		prop.ForAll(RunResourceConversionTestForServersDatabasesTransparentDataEncryption, ServersDatabasesTransparentDataEncryptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunResourceConversionTestForServersDatabasesTransparentDataEncryption tests if a specific instance of ServersDatabasesTransparentDataEncryption round trips to the hub storage version and back losslessly
func RunResourceConversionTestForServersDatabasesTransparentDataEncryption(subject ServersDatabasesTransparentDataEncryption) string {
	// Copy subject to make sure conversion doesn't modify it
	copied := subject.DeepCopy()

	// Convert to our hub version
	var hub storage.ServersDatabasesTransparentDataEncryption
	err := copied.ConvertTo(&hub)
	if err != nil {
		return err.Error()
	}

	// Convert from our hub version
	var actual ServersDatabasesTransparentDataEncryption
	err = actual.ConvertFrom(&hub)
	if err != nil {
		return err.Error()
	}

	// Compare actual with what we started with
	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 ""
}

func Test_ServersDatabasesTransparentDataEncryption_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ServersDatabasesTransparentDataEncryption to ServersDatabasesTransparentDataEncryption via AssignProperties_To_ServersDatabasesTransparentDataEncryption & AssignProperties_From_ServersDatabasesTransparentDataEncryption returns original",
		prop.ForAll(RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption, ServersDatabasesTransparentDataEncryptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption tests if a specific instance of ServersDatabasesTransparentDataEncryption can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption(subject ServersDatabasesTransparentDataEncryption) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.ServersDatabasesTransparentDataEncryption
	err := copied.AssignProperties_To_ServersDatabasesTransparentDataEncryption(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ServersDatabasesTransparentDataEncryption
	err = actual.AssignProperties_From_ServersDatabasesTransparentDataEncryption(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_ServersDatabasesTransparentDataEncryption_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 20
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of ServersDatabasesTransparentDataEncryption via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesTransparentDataEncryption, ServersDatabasesTransparentDataEncryptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesTransparentDataEncryptionGenerator returns a generator of ServersDatabasesTransparentDataEncryption instances for property testing.
func ServersDatabasesTransparentDataEncryptionGenerator() gopter.Gen {
	if serversDatabasesTransparentDataEncryptionGenerator != nil {
		return serversDatabasesTransparentDataEncryptionGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddRelatedPropertyGeneratorsForServersDatabasesTransparentDataEncryption(generators)
	serversDatabasesTransparentDataEncryptionGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesTransparentDataEncryption{}), generators)

	return serversDatabasesTransparentDataEncryptionGenerator
}

// AddRelatedPropertyGeneratorsForServersDatabasesTransparentDataEncryption is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForServersDatabasesTransparentDataEncryption(gens map[string]gopter.Gen) {
	gens["Spec"] = ServersDatabasesTransparentDataEncryption_SpecGenerator()
	gens["Status"] = ServersDatabasesTransparentDataEncryption_STATUSGenerator()
}

func Test_ServersDatabasesTransparentDataEncryptionOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ServersDatabasesTransparentDataEncryptionOperatorSpec to ServersDatabasesTransparentDataEncryptionOperatorSpec via AssignProperties_To_ServersDatabasesTransparentDataEncryptionOperatorSpec & AssignProperties_From_ServersDatabasesTransparentDataEncryptionOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryptionOperatorSpec, ServersDatabasesTransparentDataEncryptionOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryptionOperatorSpec tests if a specific instance of ServersDatabasesTransparentDataEncryptionOperatorSpec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryptionOperatorSpec(subject ServersDatabasesTransparentDataEncryptionOperatorSpec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.ServersDatabasesTransparentDataEncryptionOperatorSpec
	err := copied.AssignProperties_To_ServersDatabasesTransparentDataEncryptionOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ServersDatabasesTransparentDataEncryptionOperatorSpec
	err = actual.AssignProperties_From_ServersDatabasesTransparentDataEncryptionOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_ServersDatabasesTransparentDataEncryptionOperatorSpec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 100
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of ServersDatabasesTransparentDataEncryptionOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesTransparentDataEncryptionOperatorSpec, ServersDatabasesTransparentDataEncryptionOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesTransparentDataEncryptionOperatorSpecGenerator returns a generator of ServersDatabasesTransparentDataEncryptionOperatorSpec instances for property testing.
func ServersDatabasesTransparentDataEncryptionOperatorSpecGenerator() gopter.Gen {
	if serversDatabasesTransparentDataEncryptionOperatorSpecGenerator != nil {
		return serversDatabasesTransparentDataEncryptionOperatorSpecGenerator
	}

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

	return serversDatabasesTransparentDataEncryptionOperatorSpecGenerator
}

func Test_ServersDatabasesTransparentDataEncryption_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ServersDatabasesTransparentDataEncryption_STATUS to ServersDatabasesTransparentDataEncryption_STATUS via AssignProperties_To_ServersDatabasesTransparentDataEncryption_STATUS & AssignProperties_From_ServersDatabasesTransparentDataEncryption_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_STATUS, ServersDatabasesTransparentDataEncryption_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_STATUS tests if a specific instance of ServersDatabasesTransparentDataEncryption_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_STATUS(subject ServersDatabasesTransparentDataEncryption_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.ServersDatabasesTransparentDataEncryption_STATUS
	err := copied.AssignProperties_To_ServersDatabasesTransparentDataEncryption_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ServersDatabasesTransparentDataEncryption_STATUS
	err = actual.AssignProperties_From_ServersDatabasesTransparentDataEncryption_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_ServersDatabasesTransparentDataEncryption_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 ServersDatabasesTransparentDataEncryption_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesTransparentDataEncryption_STATUS, ServersDatabasesTransparentDataEncryption_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesTransparentDataEncryption_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 ServersDatabasesTransparentDataEncryption_STATUS instances for property testing - lazily instantiated by
// ServersDatabasesTransparentDataEncryption_STATUSGenerator()
var serversDatabasesTransparentDataEncryption_STATUSGenerator gopter.Gen

// ServersDatabasesTransparentDataEncryption_STATUSGenerator returns a generator of ServersDatabasesTransparentDataEncryption_STATUS instances for property testing.
func ServersDatabasesTransparentDataEncryption_STATUSGenerator() gopter.Gen {
	if serversDatabasesTransparentDataEncryption_STATUSGenerator != nil {
		return serversDatabasesTransparentDataEncryption_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesTransparentDataEncryption_STATUS(generators)
	serversDatabasesTransparentDataEncryption_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesTransparentDataEncryption_STATUS{}), generators)

	return serversDatabasesTransparentDataEncryption_STATUSGenerator
}

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

func Test_ServersDatabasesTransparentDataEncryption_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ServersDatabasesTransparentDataEncryption_Spec to ServersDatabasesTransparentDataEncryption_Spec via AssignProperties_To_ServersDatabasesTransparentDataEncryption_Spec & AssignProperties_From_ServersDatabasesTransparentDataEncryption_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_Spec, ServersDatabasesTransparentDataEncryption_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_Spec tests if a specific instance of ServersDatabasesTransparentDataEncryption_Spec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForServersDatabasesTransparentDataEncryption_Spec(subject ServersDatabasesTransparentDataEncryption_Spec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.ServersDatabasesTransparentDataEncryption_Spec
	err := copied.AssignProperties_To_ServersDatabasesTransparentDataEncryption_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ServersDatabasesTransparentDataEncryption_Spec
	err = actual.AssignProperties_From_ServersDatabasesTransparentDataEncryption_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_ServersDatabasesTransparentDataEncryption_Spec_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 ServersDatabasesTransparentDataEncryption_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesTransparentDataEncryption_Spec, ServersDatabasesTransparentDataEncryption_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesTransparentDataEncryption_Spec(generators)
	serversDatabasesTransparentDataEncryption_SpecGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesTransparentDataEncryption_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesTransparentDataEncryption_Spec(generators)
	AddRelatedPropertyGeneratorsForServersDatabasesTransparentDataEncryption_Spec(generators)
	serversDatabasesTransparentDataEncryption_SpecGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesTransparentDataEncryption_Spec{}), generators)

	return serversDatabasesTransparentDataEncryption_SpecGenerator
}

// AddIndependentPropertyGeneratorsForServersDatabasesTransparentDataEncryption_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForServersDatabasesTransparentDataEncryption_Spec(gens map[string]gopter.Gen) {
	gens["State"] = gen.PtrOf(gen.OneConstOf(TransparentDataEncryptionProperties_State_Disabled, TransparentDataEncryptionProperties_State_Enabled))
}

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