// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package arm

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_CaptureDescription_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 CaptureDescription via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCaptureDescription, CaptureDescriptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForCaptureDescription(generators)
	AddRelatedPropertyGeneratorsForCaptureDescription(generators)
	captureDescriptionGenerator = gen.Struct(reflect.TypeOf(CaptureDescription{}), generators)

	return captureDescriptionGenerator
}

// AddIndependentPropertyGeneratorsForCaptureDescription is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForCaptureDescription(gens map[string]gopter.Gen) {
	gens["Enabled"] = gen.PtrOf(gen.Bool())
	gens["Encoding"] = gen.PtrOf(gen.OneConstOf(CaptureDescription_Encoding_Avro, CaptureDescription_Encoding_AvroDeflate))
	gens["IntervalInSeconds"] = gen.PtrOf(gen.Int())
	gens["SizeLimitInBytes"] = gen.PtrOf(gen.Int())
	gens["SkipEmptyArchives"] = gen.PtrOf(gen.Bool())
}

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

func Test_Destination_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 Destination via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDestination, DestinationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForDestination(generators)
	AddRelatedPropertyGeneratorsForDestination(generators)
	destinationGenerator = gen.Struct(reflect.TypeOf(Destination{}), generators)

	return destinationGenerator
}

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

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

func Test_Destination_Properties_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 Destination_Properties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDestination_Properties, Destination_PropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// Destination_PropertiesGenerator returns a generator of Destination_Properties instances for property testing.
func Destination_PropertiesGenerator() gopter.Gen {
	if destination_PropertiesGenerator != nil {
		return destination_PropertiesGenerator
	}

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

	return destination_PropertiesGenerator
}

// AddIndependentPropertyGeneratorsForDestination_Properties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDestination_Properties(gens map[string]gopter.Gen) {
	gens["ArchiveNameFormat"] = gen.PtrOf(gen.AlphaString())
	gens["BlobContainer"] = gen.PtrOf(gen.AlphaString())
	gens["DataLakeAccountName"] = gen.PtrOf(gen.AlphaString())
	gens["DataLakeFolderPath"] = gen.PtrOf(gen.AlphaString())
	gens["DataLakeSubscriptionId"] = gen.PtrOf(gen.AlphaString())
	gens["StorageAccountResourceId"] = gen.PtrOf(gen.AlphaString())
}

func Test_NamespacesEventhub_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 NamespacesEventhub_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNamespacesEventhub_Spec, NamespacesEventhub_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual NamespacesEventhub_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 NamespacesEventhub_Spec instances for property testing - lazily instantiated by
// NamespacesEventhub_SpecGenerator()
var namespacesEventhub_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNamespacesEventhub_Spec(generators)
	AddRelatedPropertyGeneratorsForNamespacesEventhub_Spec(generators)
	namespacesEventhub_SpecGenerator = gen.Struct(reflect.TypeOf(NamespacesEventhub_Spec{}), generators)

	return namespacesEventhub_SpecGenerator
}

// AddIndependentPropertyGeneratorsForNamespacesEventhub_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForNamespacesEventhub_Spec(gens map[string]gopter.Gen) {
	gens["Name"] = gen.AlphaString()
}

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

func Test_Namespaces_Eventhub_Properties_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 Namespaces_Eventhub_Properties_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNamespaces_Eventhub_Properties_Spec, Namespaces_Eventhub_Properties_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Namespaces_Eventhub_Properties_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 Namespaces_Eventhub_Properties_Spec instances for property testing - lazily instantiated by
// Namespaces_Eventhub_Properties_SpecGenerator()
var namespaces_Eventhub_Properties_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNamespaces_Eventhub_Properties_Spec(generators)
	AddRelatedPropertyGeneratorsForNamespaces_Eventhub_Properties_Spec(generators)
	namespaces_Eventhub_Properties_SpecGenerator = gen.Struct(reflect.TypeOf(Namespaces_Eventhub_Properties_Spec{}), generators)

	return namespaces_Eventhub_Properties_SpecGenerator
}

// AddIndependentPropertyGeneratorsForNamespaces_Eventhub_Properties_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForNamespaces_Eventhub_Properties_Spec(gens map[string]gopter.Gen) {
	gens["MessageRetentionInDays"] = gen.PtrOf(gen.Int())
	gens["PartitionCount"] = gen.PtrOf(gen.Int())
}

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