// 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_ServersDatabasesBackupShortTermRetentionPolicy_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 ServersDatabasesBackupShortTermRetentionPolicy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupShortTermRetentionPolicy, ServersDatabasesBackupShortTermRetentionPolicyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesBackupShortTermRetentionPolicyGenerator returns a generator of ServersDatabasesBackupShortTermRetentionPolicy instances for property testing.
func ServersDatabasesBackupShortTermRetentionPolicyGenerator() gopter.Gen {
	if serversDatabasesBackupShortTermRetentionPolicyGenerator != nil {
		return serversDatabasesBackupShortTermRetentionPolicyGenerator
	}

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

	return serversDatabasesBackupShortTermRetentionPolicyGenerator
}

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

func Test_ServersDatabasesBackupShortTermRetentionPolicyOperatorSpec_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 ServersDatabasesBackupShortTermRetentionPolicyOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupShortTermRetentionPolicyOperatorSpec, ServersDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ServersDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator returns a generator of ServersDatabasesBackupShortTermRetentionPolicyOperatorSpec instances for property testing.
func ServersDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator() gopter.Gen {
	if serversDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator != nil {
		return serversDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator
	}

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

	return serversDatabasesBackupShortTermRetentionPolicyOperatorSpecGenerator
}

func Test_ServersDatabasesBackupShortTermRetentionPolicy_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 ServersDatabasesBackupShortTermRetentionPolicy_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupShortTermRetentionPolicy_STATUS, ServersDatabasesBackupShortTermRetentionPolicy_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesBackupShortTermRetentionPolicy_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 ServersDatabasesBackupShortTermRetentionPolicy_STATUS instances for property testing - lazily
// instantiated by ServersDatabasesBackupShortTermRetentionPolicy_STATUSGenerator()
var serversDatabasesBackupShortTermRetentionPolicy_STATUSGenerator gopter.Gen

// ServersDatabasesBackupShortTermRetentionPolicy_STATUSGenerator returns a generator of ServersDatabasesBackupShortTermRetentionPolicy_STATUS instances for property testing.
func ServersDatabasesBackupShortTermRetentionPolicy_STATUSGenerator() gopter.Gen {
	if serversDatabasesBackupShortTermRetentionPolicy_STATUSGenerator != nil {
		return serversDatabasesBackupShortTermRetentionPolicy_STATUSGenerator
	}

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

	return serversDatabasesBackupShortTermRetentionPolicy_STATUSGenerator
}

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

func Test_ServersDatabasesBackupShortTermRetentionPolicy_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 ServersDatabasesBackupShortTermRetentionPolicy_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersDatabasesBackupShortTermRetentionPolicy_Spec, ServersDatabasesBackupShortTermRetentionPolicy_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersDatabasesBackupShortTermRetentionPolicy_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 ServersDatabasesBackupShortTermRetentionPolicy_Spec instances for property testing - lazily instantiated
// by ServersDatabasesBackupShortTermRetentionPolicy_SpecGenerator()
var serversDatabasesBackupShortTermRetentionPolicy_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersDatabasesBackupShortTermRetentionPolicy_Spec(generators)
	AddRelatedPropertyGeneratorsForServersDatabasesBackupShortTermRetentionPolicy_Spec(generators)
	serversDatabasesBackupShortTermRetentionPolicy_SpecGenerator = gen.Struct(reflect.TypeOf(ServersDatabasesBackupShortTermRetentionPolicy_Spec{}), generators)

	return serversDatabasesBackupShortTermRetentionPolicy_SpecGenerator
}

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

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