// 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_DnsZonesCNAMERecord_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 DnsZonesCNAMERecord via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesCNAMERecord, DnsZonesCNAMERecordGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsZonesCNAMERecordGenerator returns a generator of DnsZonesCNAMERecord instances for property testing.
func DnsZonesCNAMERecordGenerator() gopter.Gen {
	if dnsZonesCNAMERecordGenerator != nil {
		return dnsZonesCNAMERecordGenerator
	}

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

	return dnsZonesCNAMERecordGenerator
}

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

func Test_DnsZonesCNAMERecordOperatorSpec_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 DnsZonesCNAMERecordOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesCNAMERecordOperatorSpec, DnsZonesCNAMERecordOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsZonesCNAMERecordOperatorSpecGenerator returns a generator of DnsZonesCNAMERecordOperatorSpec instances for property testing.
func DnsZonesCNAMERecordOperatorSpecGenerator() gopter.Gen {
	if dnsZonesCNAMERecordOperatorSpecGenerator != nil {
		return dnsZonesCNAMERecordOperatorSpecGenerator
	}

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

	return dnsZonesCNAMERecordOperatorSpecGenerator
}

func Test_DnsZonesCNAMERecord_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 DnsZonesCNAMERecord_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesCNAMERecord_STATUS, DnsZonesCNAMERecord_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsZonesCNAMERecord_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 DnsZonesCNAMERecord_STATUS instances for property testing - lazily instantiated by
// DnsZonesCNAMERecord_STATUSGenerator()
var dnsZonesCNAMERecord_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_STATUS(generators)
	AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_STATUS(generators)
	dnsZonesCNAMERecord_STATUSGenerator = gen.Struct(reflect.TypeOf(DnsZonesCNAMERecord_STATUS{}), generators)

	return dnsZonesCNAMERecord_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_STATUS(gens map[string]gopter.Gen) {
	gens["Etag"] = gen.PtrOf(gen.AlphaString())
	gens["Fqdn"] = gen.PtrOf(gen.AlphaString())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Metadata"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["ProvisioningState"] = gen.PtrOf(gen.AlphaString())
	gens["TTL"] = gen.PtrOf(gen.Int())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_STATUS(gens map[string]gopter.Gen) {
	gens["AAAARecords"] = gen.SliceOf(AaaaRecord_STATUSGenerator())
	gens["ARecords"] = gen.SliceOf(ARecord_STATUSGenerator())
	gens["CNAMERecord"] = gen.PtrOf(CnameRecord_STATUSGenerator())
	gens["CaaRecords"] = gen.SliceOf(CaaRecord_STATUSGenerator())
	gens["MXRecords"] = gen.SliceOf(MxRecord_STATUSGenerator())
	gens["NSRecords"] = gen.SliceOf(NsRecord_STATUSGenerator())
	gens["PTRRecords"] = gen.SliceOf(PtrRecord_STATUSGenerator())
	gens["SOARecord"] = gen.PtrOf(SoaRecord_STATUSGenerator())
	gens["SRVRecords"] = gen.SliceOf(SrvRecord_STATUSGenerator())
	gens["TXTRecords"] = gen.SliceOf(TxtRecord_STATUSGenerator())
	gens["TargetResource"] = gen.PtrOf(SubResource_STATUSGenerator())
}

func Test_DnsZonesCNAMERecord_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 DnsZonesCNAMERecord_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesCNAMERecord_Spec, DnsZonesCNAMERecord_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsZonesCNAMERecord_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 DnsZonesCNAMERecord_Spec instances for property testing - lazily instantiated by
// DnsZonesCNAMERecord_SpecGenerator()
var dnsZonesCNAMERecord_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_Spec(generators)
	AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_Spec(generators)
	dnsZonesCNAMERecord_SpecGenerator = gen.Struct(reflect.TypeOf(DnsZonesCNAMERecord_Spec{}), generators)

	return dnsZonesCNAMERecord_SpecGenerator
}

// AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDnsZonesCNAMERecord_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["Metadata"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["TTL"] = gen.PtrOf(gen.Int())
}

// AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDnsZonesCNAMERecord_Spec(gens map[string]gopter.Gen) {
	gens["AAAARecords"] = gen.SliceOf(AaaaRecordGenerator())
	gens["ARecords"] = gen.SliceOf(ARecordGenerator())
	gens["CNAMERecord"] = gen.PtrOf(CnameRecordGenerator())
	gens["CaaRecords"] = gen.SliceOf(CaaRecordGenerator())
	gens["MXRecords"] = gen.SliceOf(MxRecordGenerator())
	gens["NSRecords"] = gen.SliceOf(NsRecordGenerator())
	gens["OperatorSpec"] = gen.PtrOf(DnsZonesCNAMERecordOperatorSpecGenerator())
	gens["PTRRecords"] = gen.SliceOf(PtrRecordGenerator())
	gens["SOARecord"] = gen.PtrOf(SoaRecordGenerator())
	gens["SRVRecords"] = gen.SliceOf(SrvRecordGenerator())
	gens["TXTRecords"] = gen.SliceOf(TxtRecordGenerator())
	gens["TargetResource"] = gen.PtrOf(SubResourceGenerator())
}
