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

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_ServersVulnerabilityAssessment_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 ServersVulnerabilityAssessment via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersVulnerabilityAssessment, ServersVulnerabilityAssessmentGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersVulnerabilityAssessmentGenerator returns a generator of ServersVulnerabilityAssessment instances for property testing.
func ServersVulnerabilityAssessmentGenerator() gopter.Gen {
	if serversVulnerabilityAssessmentGenerator != nil {
		return serversVulnerabilityAssessmentGenerator
	}

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

	return serversVulnerabilityAssessmentGenerator
}

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

func Test_ServersVulnerabilityAssessmentOperatorSpec_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 ServersVulnerabilityAssessmentOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersVulnerabilityAssessmentOperatorSpec, ServersVulnerabilityAssessmentOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersVulnerabilityAssessmentOperatorSpecGenerator returns a generator of ServersVulnerabilityAssessmentOperatorSpec instances for property testing.
func ServersVulnerabilityAssessmentOperatorSpecGenerator() gopter.Gen {
	if serversVulnerabilityAssessmentOperatorSpecGenerator != nil {
		return serversVulnerabilityAssessmentOperatorSpecGenerator
	}

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

	return serversVulnerabilityAssessmentOperatorSpecGenerator
}

func Test_ServersVulnerabilityAssessment_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 ServersVulnerabilityAssessment_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersVulnerabilityAssessment_STATUS, ServersVulnerabilityAssessment_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersVulnerabilityAssessment_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 ServersVulnerabilityAssessment_STATUS instances for property testing - lazily instantiated by
// ServersVulnerabilityAssessment_STATUSGenerator()
var serversVulnerabilityAssessment_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersVulnerabilityAssessment_STATUS(generators)
	AddRelatedPropertyGeneratorsForServersVulnerabilityAssessment_STATUS(generators)
	serversVulnerabilityAssessment_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersVulnerabilityAssessment_STATUS{}), generators)

	return serversVulnerabilityAssessment_STATUSGenerator
}

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

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

func Test_ServersVulnerabilityAssessment_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 ServersVulnerabilityAssessment_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersVulnerabilityAssessment_Spec, ServersVulnerabilityAssessment_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersVulnerabilityAssessment_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 ServersVulnerabilityAssessment_Spec instances for property testing - lazily instantiated by
// ServersVulnerabilityAssessment_SpecGenerator()
var serversVulnerabilityAssessment_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersVulnerabilityAssessment_Spec(generators)
	AddRelatedPropertyGeneratorsForServersVulnerabilityAssessment_Spec(generators)
	serversVulnerabilityAssessment_SpecGenerator = gen.Struct(reflect.TypeOf(ServersVulnerabilityAssessment_Spec{}), generators)

	return serversVulnerabilityAssessment_SpecGenerator
}

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

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