// 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_DnsForwardingRuleSetsVirtualNetworkLink_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 DnsForwardingRuleSetsVirtualNetworkLink via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsForwardingRuleSetsVirtualNetworkLink, DnsForwardingRuleSetsVirtualNetworkLinkGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsForwardingRuleSetsVirtualNetworkLinkGenerator returns a generator of DnsForwardingRuleSetsVirtualNetworkLink instances for property testing.
func DnsForwardingRuleSetsVirtualNetworkLinkGenerator() gopter.Gen {
	if dnsForwardingRuleSetsVirtualNetworkLinkGenerator != nil {
		return dnsForwardingRuleSetsVirtualNetworkLinkGenerator
	}

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

	return dnsForwardingRuleSetsVirtualNetworkLinkGenerator
}

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

func Test_DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpec_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 DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsForwardingRuleSetsVirtualNetworkLinkOperatorSpec, DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator returns a generator of DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpec instances for property testing.
func DnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator() gopter.Gen {
	if dnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator != nil {
		return dnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator
	}

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

	return dnsForwardingRuleSetsVirtualNetworkLinkOperatorSpecGenerator
}

func Test_DnsForwardingRuleSetsVirtualNetworkLink_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 DnsForwardingRuleSetsVirtualNetworkLink_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsForwardingRuleSetsVirtualNetworkLink_STATUS, DnsForwardingRuleSetsVirtualNetworkLink_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsForwardingRuleSetsVirtualNetworkLink_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 DnsForwardingRuleSetsVirtualNetworkLink_STATUS instances for property testing - lazily instantiated by
// DnsForwardingRuleSetsVirtualNetworkLink_STATUSGenerator()
var dnsForwardingRuleSetsVirtualNetworkLink_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_STATUS(generators)
	AddRelatedPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_STATUS(generators)
	dnsForwardingRuleSetsVirtualNetworkLink_STATUSGenerator = gen.Struct(reflect.TypeOf(DnsForwardingRuleSetsVirtualNetworkLink_STATUS{}), generators)

	return dnsForwardingRuleSetsVirtualNetworkLink_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_STATUS(gens map[string]gopter.Gen) {
	gens["Etag"] = 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["Type"] = gen.PtrOf(gen.AlphaString())
}

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

func Test_DnsForwardingRuleSetsVirtualNetworkLink_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 DnsForwardingRuleSetsVirtualNetworkLink_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDnsForwardingRuleSetsVirtualNetworkLink_Spec, DnsForwardingRuleSetsVirtualNetworkLink_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual DnsForwardingRuleSetsVirtualNetworkLink_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 DnsForwardingRuleSetsVirtualNetworkLink_Spec instances for property testing - lazily instantiated by
// DnsForwardingRuleSetsVirtualNetworkLink_SpecGenerator()
var dnsForwardingRuleSetsVirtualNetworkLink_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_Spec(generators)
	AddRelatedPropertyGeneratorsForDnsForwardingRuleSetsVirtualNetworkLink_Spec(generators)
	dnsForwardingRuleSetsVirtualNetworkLink_SpecGenerator = gen.Struct(reflect.TypeOf(DnsForwardingRuleSetsVirtualNetworkLink_Spec{}), generators)

	return dnsForwardingRuleSetsVirtualNetworkLink_SpecGenerator
}

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

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