// 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_DiskEncryptionSet_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 DiskEncryptionSet_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDiskEncryptionSet_Spec, DiskEncryptionSet_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DiskEncryptionSet_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 DiskEncryptionSet_Spec instances for property testing - lazily instantiated by
// DiskEncryptionSet_SpecGenerator()
var diskEncryptionSet_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDiskEncryptionSet_Spec(generators)
	AddRelatedPropertyGeneratorsForDiskEncryptionSet_Spec(generators)
	diskEncryptionSet_SpecGenerator = gen.Struct(reflect.TypeOf(DiskEncryptionSet_Spec{}), generators)

	return diskEncryptionSet_SpecGenerator
}

// AddIndependentPropertyGeneratorsForDiskEncryptionSet_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDiskEncryptionSet_Spec(gens map[string]gopter.Gen) {
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.AlphaString()
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
}

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

func Test_EncryptionSetIdentity_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 EncryptionSetIdentity via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForEncryptionSetIdentity, EncryptionSetIdentityGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEncryptionSetIdentity(generators)
	AddRelatedPropertyGeneratorsForEncryptionSetIdentity(generators)
	encryptionSetIdentityGenerator = gen.Struct(reflect.TypeOf(EncryptionSetIdentity{}), generators)

	return encryptionSetIdentityGenerator
}

// AddIndependentPropertyGeneratorsForEncryptionSetIdentity is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForEncryptionSetIdentity(gens map[string]gopter.Gen) {
	gens["Type"] = gen.PtrOf(gen.OneConstOf(
		EncryptionSetIdentity_Type_None,
		EncryptionSetIdentity_Type_SystemAssigned,
		EncryptionSetIdentity_Type_SystemAssignedUserAssigned,
		EncryptionSetIdentity_Type_UserAssigned))
}

// AddRelatedPropertyGeneratorsForEncryptionSetIdentity is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForEncryptionSetIdentity(gens map[string]gopter.Gen) {
	gens["UserAssignedIdentities"] = gen.MapOf(
		gen.AlphaString(),
		UserAssignedIdentityDetailsGenerator())
}

func Test_EncryptionSetProperties_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 EncryptionSetProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForEncryptionSetProperties, EncryptionSetPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForEncryptionSetProperties(generators)
	AddRelatedPropertyGeneratorsForEncryptionSetProperties(generators)
	encryptionSetPropertiesGenerator = gen.Struct(reflect.TypeOf(EncryptionSetProperties{}), generators)

	return encryptionSetPropertiesGenerator
}

// AddIndependentPropertyGeneratorsForEncryptionSetProperties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForEncryptionSetProperties(gens map[string]gopter.Gen) {
	gens["EncryptionType"] = gen.PtrOf(gen.OneConstOf(DiskEncryptionSetType_ConfidentialVmEncryptedWithCustomerKey, DiskEncryptionSetType_EncryptionAtRestWithCustomerKey, DiskEncryptionSetType_EncryptionAtRestWithPlatformAndCustomerKeys))
	gens["FederatedClientId"] = gen.PtrOf(gen.AlphaString())
	gens["RotationToLatestKeyVersionEnabled"] = gen.PtrOf(gen.Bool())
}

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

func Test_KeyForDiskEncryptionSet_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 KeyForDiskEncryptionSet via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForKeyForDiskEncryptionSet, KeyForDiskEncryptionSetGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForKeyForDiskEncryptionSet(generators)
	AddRelatedPropertyGeneratorsForKeyForDiskEncryptionSet(generators)
	keyForDiskEncryptionSetGenerator = gen.Struct(reflect.TypeOf(KeyForDiskEncryptionSet{}), generators)

	return keyForDiskEncryptionSetGenerator
}

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

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

func Test_SourceVault_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 SourceVault via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSourceVault, SourceVaultGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// SourceVaultGenerator returns a generator of SourceVault instances for property testing.
func SourceVaultGenerator() gopter.Gen {
	if sourceVaultGenerator != nil {
		return sourceVaultGenerator
	}

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

	return sourceVaultGenerator
}

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

func Test_UserAssignedIdentityDetails_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 UserAssignedIdentityDetails via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForUserAssignedIdentityDetails, UserAssignedIdentityDetailsGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// UserAssignedIdentityDetailsGenerator returns a generator of UserAssignedIdentityDetails instances for property testing.
func UserAssignedIdentityDetailsGenerator() gopter.Gen {
	if userAssignedIdentityDetailsGenerator != nil {
		return userAssignedIdentityDetailsGenerator
	}

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

	return userAssignedIdentityDetailsGenerator
}
