// 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_RegistryReplication_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 RegistryReplication via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRegistryReplication, RegistryReplicationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// RegistryReplicationGenerator returns a generator of RegistryReplication instances for property testing.
func RegistryReplicationGenerator() gopter.Gen {
	if registryReplicationGenerator != nil {
		return registryReplicationGenerator
	}

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

	return registryReplicationGenerator
}

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

func Test_RegistryReplicationOperatorSpec_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 RegistryReplicationOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRegistryReplicationOperatorSpec, RegistryReplicationOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// RegistryReplicationOperatorSpecGenerator returns a generator of RegistryReplicationOperatorSpec instances for property testing.
func RegistryReplicationOperatorSpecGenerator() gopter.Gen {
	if registryReplicationOperatorSpecGenerator != nil {
		return registryReplicationOperatorSpecGenerator
	}

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

	return registryReplicationOperatorSpecGenerator
}

func Test_RegistryReplication_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 RegistryReplication_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRegistryReplication_STATUS, RegistryReplication_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RegistryReplication_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 RegistryReplication_STATUS instances for property testing - lazily instantiated by
// RegistryReplication_STATUSGenerator()
var registryReplication_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRegistryReplication_STATUS(generators)
	AddRelatedPropertyGeneratorsForRegistryReplication_STATUS(generators)
	registryReplication_STATUSGenerator = gen.Struct(reflect.TypeOf(RegistryReplication_STATUS{}), generators)

	return registryReplication_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForRegistryReplication_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRegistryReplication_STATUS(gens map[string]gopter.Gen) {
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["ProvisioningState"] = gen.PtrOf(gen.AlphaString())
	gens["RegionEndpointEnabled"] = gen.PtrOf(gen.Bool())
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
	gens["ZoneRedundancy"] = gen.PtrOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForRegistryReplication_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForRegistryReplication_STATUS(gens map[string]gopter.Gen) {
	gens["Status"] = gen.PtrOf(Status_STATUSGenerator())
	gens["SystemData"] = gen.PtrOf(SystemData_STATUSGenerator())
}

func Test_RegistryReplication_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 RegistryReplication_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRegistryReplication_Spec, RegistryReplication_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RegistryReplication_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 RegistryReplication_Spec instances for property testing - lazily instantiated by
// RegistryReplication_SpecGenerator()
var registryReplication_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRegistryReplication_Spec(generators)
	AddRelatedPropertyGeneratorsForRegistryReplication_Spec(generators)
	registryReplication_SpecGenerator = gen.Struct(reflect.TypeOf(RegistryReplication_Spec{}), generators)

	return registryReplication_SpecGenerator
}

// AddIndependentPropertyGeneratorsForRegistryReplication_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRegistryReplication_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["RegionEndpointEnabled"] = gen.PtrOf(gen.Bool())
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["ZoneRedundancy"] = gen.PtrOf(gen.AlphaString())
}

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