// 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_DnsZonesPTRRecord_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 DnsZonesPTRRecord via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesPTRRecord, DnsZonesPTRRecordGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsZonesPTRRecordGenerator returns a generator of DnsZonesPTRRecord instances for property testing.
func DnsZonesPTRRecordGenerator() gopter.Gen {
	if dnsZonesPTRRecordGenerator != nil {
		return dnsZonesPTRRecordGenerator
	}

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

	return dnsZonesPTRRecordGenerator
}

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

func Test_DnsZonesPTRRecordOperatorSpec_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 DnsZonesPTRRecordOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesPTRRecordOperatorSpec, DnsZonesPTRRecordOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsZonesPTRRecordOperatorSpecGenerator returns a generator of DnsZonesPTRRecordOperatorSpec instances for property testing.
func DnsZonesPTRRecordOperatorSpecGenerator() gopter.Gen {
	if dnsZonesPTRRecordOperatorSpecGenerator != nil {
		return dnsZonesPTRRecordOperatorSpecGenerator
	}

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

	return dnsZonesPTRRecordOperatorSpecGenerator
}

func Test_DnsZonesPTRRecord_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 DnsZonesPTRRecord_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesPTRRecord_STATUS, DnsZonesPTRRecord_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsZonesPTRRecord_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 DnsZonesPTRRecord_STATUS instances for property testing - lazily instantiated by
// DnsZonesPTRRecord_STATUSGenerator()
var dnsZonesPTRRecord_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_STATUS(generators)
	AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_STATUS(generators)
	dnsZonesPTRRecord_STATUSGenerator = gen.Struct(reflect.TypeOf(DnsZonesPTRRecord_STATUS{}), generators)

	return dnsZonesPTRRecord_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_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())
}

// AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_STATUS is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_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_DnsZonesPTRRecord_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 DnsZonesPTRRecord_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsZonesPTRRecord_Spec, DnsZonesPTRRecord_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsZonesPTRRecord_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 DnsZonesPTRRecord_Spec instances for property testing - lazily instantiated by
// DnsZonesPTRRecord_SpecGenerator()
var dnsZonesPTRRecord_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_Spec(generators)
	AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_Spec(generators)
	dnsZonesPTRRecord_SpecGenerator = gen.Struct(reflect.TypeOf(DnsZonesPTRRecord_Spec{}), generators)

	return dnsZonesPTRRecord_SpecGenerator
}

// AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDnsZonesPTRRecord_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())
}

// AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForDnsZonesPTRRecord_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(DnsZonesPTRRecordOperatorSpecGenerator())
	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())
}
