// 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_DatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties_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 DatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties, DatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties(generators)
	AddRelatedPropertyGeneratorsForDatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties(generators)
	databaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentPropertiesGenerator = gen.Struct(reflect.TypeOf(DatabaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentProperties{}), generators)

	return databaseVulnerabilityAssessmentsDatabaseVulnerabilityAssessmentPropertiesGenerator
}

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

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

func Test_ServersDatabasesVulnerabilityAssessment_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 ServersDatabasesVulnerabilityAssessment_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesVulnerabilityAssessment_Spec, ServersDatabasesVulnerabilityAssessment_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesVulnerabilityAssessment_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 ServersDatabasesVulnerabilityAssessment_Spec instances for property testing - lazily instantiated by
// ServersDatabasesVulnerabilityAssessment_SpecGenerator()
var serversDatabasesVulnerabilityAssessment_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesVulnerabilityAssessment_Spec(generators)
	AddRelatedPropertyGeneratorsForServersDatabasesVulnerabilityAssessment_Spec(generators)
	serversDatabasesVulnerabilityAssessment_SpecGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesVulnerabilityAssessment_Spec{}), generators)

	return serversDatabasesVulnerabilityAssessment_SpecGenerator
}

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

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

func Test_VulnerabilityAssessmentRecurringScansProperties_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 VulnerabilityAssessmentRecurringScansProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForVulnerabilityAssessmentRecurringScansProperties, VulnerabilityAssessmentRecurringScansPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// VulnerabilityAssessmentRecurringScansPropertiesGenerator returns a generator of VulnerabilityAssessmentRecurringScansProperties instances for property testing.
func VulnerabilityAssessmentRecurringScansPropertiesGenerator() gopter.Gen {
	if vulnerabilityAssessmentRecurringScansPropertiesGenerator != nil {
		return vulnerabilityAssessmentRecurringScansPropertiesGenerator
	}

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

	return vulnerabilityAssessmentRecurringScansPropertiesGenerator
}

// AddIndependentPropertyGeneratorsForVulnerabilityAssessmentRecurringScansProperties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForVulnerabilityAssessmentRecurringScansProperties(gens map[string]gopter.Gen) {
	gens["EmailSubscriptionAdmins"] = gen.PtrOf(gen.Bool())
	gens["Emails"] = gen.SliceOf(gen.AlphaString())
	gens["IsEnabled"] = gen.PtrOf(gen.Bool())
}
