// 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_ServersDatabasesBackupLongTermRetentionPolicy_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 ServersDatabasesBackupLongTermRetentionPolicy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupLongTermRetentionPolicy, ServersDatabasesBackupLongTermRetentionPolicyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesBackupLongTermRetentionPolicyGenerator returns a generator of ServersDatabasesBackupLongTermRetentionPolicy instances for property testing.
func ServersDatabasesBackupLongTermRetentionPolicyGenerator() gopter.Gen {
	if serversDatabasesBackupLongTermRetentionPolicyGenerator != nil {
		return serversDatabasesBackupLongTermRetentionPolicyGenerator
	}

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

	return serversDatabasesBackupLongTermRetentionPolicyGenerator
}

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

func Test_ServersDatabasesBackupLongTermRetentionPolicyOperatorSpec_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 ServersDatabasesBackupLongTermRetentionPolicyOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupLongTermRetentionPolicyOperatorSpec, ServersDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator returns a generator of ServersDatabasesBackupLongTermRetentionPolicyOperatorSpec instances for property testing.
func ServersDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator() gopter.Gen {
	if serversDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator != nil {
		return serversDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator
	}

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

	return serversDatabasesBackupLongTermRetentionPolicyOperatorSpecGenerator
}

func Test_ServersDatabasesBackupLongTermRetentionPolicy_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 ServersDatabasesBackupLongTermRetentionPolicy_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupLongTermRetentionPolicy_STATUS, ServersDatabasesBackupLongTermRetentionPolicy_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesBackupLongTermRetentionPolicy_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 ServersDatabasesBackupLongTermRetentionPolicy_STATUS instances for property testing - lazily
// instantiated by ServersDatabasesBackupLongTermRetentionPolicy_STATUSGenerator()
var serversDatabasesBackupLongTermRetentionPolicy_STATUSGenerator gopter.Gen

// ServersDatabasesBackupLongTermRetentionPolicy_STATUSGenerator returns a generator of ServersDatabasesBackupLongTermRetentionPolicy_STATUS instances for property testing.
func ServersDatabasesBackupLongTermRetentionPolicy_STATUSGenerator() gopter.Gen {
	if serversDatabasesBackupLongTermRetentionPolicy_STATUSGenerator != nil {
		return serversDatabasesBackupLongTermRetentionPolicy_STATUSGenerator
	}

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

	return serversDatabasesBackupLongTermRetentionPolicy_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_STATUS(gens map[string]gopter.Gen) {
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["MonthlyRetention"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
	gens["WeekOfYear"] = gen.PtrOf(gen.Int())
	gens["WeeklyRetention"] = gen.PtrOf(gen.AlphaString())
	gens["YearlyRetention"] = gen.PtrOf(gen.AlphaString())
}

func Test_ServersDatabasesBackupLongTermRetentionPolicy_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 ServersDatabasesBackupLongTermRetentionPolicy_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupLongTermRetentionPolicy_Spec, ServersDatabasesBackupLongTermRetentionPolicy_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesBackupLongTermRetentionPolicy_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 ServersDatabasesBackupLongTermRetentionPolicy_Spec instances for property testing - lazily instantiated
// by ServersDatabasesBackupLongTermRetentionPolicy_SpecGenerator()
var serversDatabasesBackupLongTermRetentionPolicy_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_Spec(generators)
	AddRelatedPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_Spec(generators)
	serversDatabasesBackupLongTermRetentionPolicy_SpecGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesBackupLongTermRetentionPolicy_Spec{}), generators)

	return serversDatabasesBackupLongTermRetentionPolicy_SpecGenerator
}

// AddIndependentPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForServersDatabasesBackupLongTermRetentionPolicy_Spec(gens map[string]gopter.Gen) {
	gens["MonthlyRetention"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["WeekOfYear"] = gen.PtrOf(gen.Int())
	gens["WeeklyRetention"] = gen.PtrOf(gen.AlphaString())
	gens["YearlyRetention"] = gen.PtrOf(gen.AlphaString())
}

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