package v1beta20201101

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_RouteTables_SpecARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_SpecARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecARM, RouteTablesSpecARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

func RunJSONSerializationTestForRouteTablesSpecARM(subject RouteTables_SpecARM) string {

	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	var actual RouteTables_SpecARM
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	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 ""
}

var routeTablesSpecARMGenerator gopter.Gen

func RouteTablesSpecARMGenerator() gopter.Gen {
	if routeTablesSpecARMGenerator != nil {
		return routeTablesSpecARMGenerator
	}

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

	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecARM(generators)
	routeTablesSpecARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_SpecARM{}), generators)

	return routeTablesSpecARMGenerator
}

func AddIndependentPropertyGeneratorsForRouteTablesSpecARM(gens map[string]gopter.Gen) {
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.AlphaString()
	gens["Tags"] = gen.MapOf(gen.AlphaString(), gen.AlphaString())
}

func AddRelatedPropertyGeneratorsForRouteTablesSpecARM(gens map[string]gopter.Gen) {
	gens["Properties"] = gen.PtrOf(RouteTablesSpecPropertiesARMGenerator())
}

func Test_RouteTables_Spec_PropertiesARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_Spec_PropertiesARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecPropertiesARM, RouteTablesSpecPropertiesARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

func RunJSONSerializationTestForRouteTablesSpecPropertiesARM(subject RouteTables_Spec_PropertiesARM) string {

	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	var actual RouteTables_Spec_PropertiesARM
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	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 ""
}

var routeTablesSpecPropertiesARMGenerator gopter.Gen

func RouteTablesSpecPropertiesARMGenerator() gopter.Gen {
	if routeTablesSpecPropertiesARMGenerator != nil {
		return routeTablesSpecPropertiesARMGenerator
	}

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

	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesARM(generators)
	routeTablesSpecPropertiesARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_Spec_PropertiesARM{}), generators)

	return routeTablesSpecPropertiesARMGenerator
}

func AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesARM(gens map[string]gopter.Gen) {
	gens["DisableBgpRoutePropagation"] = gen.PtrOf(gen.Bool())
}

func AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesARM(gens map[string]gopter.Gen) {
	gens["Routes"] = gen.SliceOf(RouteTablesSpecPropertiesRoutesARMGenerator())
}

func Test_RouteTables_Spec_Properties_RoutesARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_Spec_Properties_RoutesARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecPropertiesRoutesARM, RouteTablesSpecPropertiesRoutesARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

func RunJSONSerializationTestForRouteTablesSpecPropertiesRoutesARM(subject RouteTables_Spec_Properties_RoutesARM) string {

	bin, err := json.Marshal(subject)
	if err != nil {
		return err.Error()
	}

	var actual RouteTables_Spec_Properties_RoutesARM
	err = json.Unmarshal(bin, &actual)
	if err != nil {
		return err.Error()
	}

	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 ""
}

var routeTablesSpecPropertiesRoutesARMGenerator gopter.Gen

func RouteTablesSpecPropertiesRoutesARMGenerator() gopter.Gen {
	if routeTablesSpecPropertiesRoutesARMGenerator != nil {
		return routeTablesSpecPropertiesRoutesARMGenerator
	}

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

	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(generators)
	routeTablesSpecPropertiesRoutesARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_Spec_Properties_RoutesARM{}), generators)

	return routeTablesSpecPropertiesRoutesARMGenerator
}

func AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(gens map[string]gopter.Gen) {
	gens["Name"] = gen.PtrOf(gen.AlphaString())
}

func AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(gens map[string]gopter.Gen) {
	gens["Properties"] = gen.PtrOf(RoutePropertiesFormatARMGenerator())
}
// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package v1beta20201101

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_RouteTables_SpecARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_SpecARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecARM, RouteTablesSpecARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecARM(generators)
	routeTablesSpecARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_SpecARM{}), generators)

	return routeTablesSpecARMGenerator
}

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

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

func Test_RouteTables_Spec_PropertiesARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_Spec_PropertiesARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecPropertiesARM, RouteTablesSpecPropertiesARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesARM(generators)
	routeTablesSpecPropertiesARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_Spec_PropertiesARM{}), generators)

	return routeTablesSpecPropertiesARMGenerator
}

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

// AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesARM is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesARM(gens map[string]gopter.Gen) {
	gens["Routes"] = gen.SliceOf(RouteTablesSpecPropertiesRoutesARMGenerator())
}

func Test_RouteTables_Spec_Properties_RoutesARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of RouteTables_Spec_Properties_RoutesARM via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablesSpecPropertiesRoutesARM, RouteTablesSpecPropertiesRoutesARMGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(generators)
	AddRelatedPropertyGeneratorsForRouteTablesSpecPropertiesRoutesARM(generators)
	routeTablesSpecPropertiesRoutesARMGenerator = gen.Struct(reflect.TypeOf(RouteTables_Spec_Properties_RoutesARM{}), generators)

	return routeTablesSpecPropertiesRoutesARMGenerator
}

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

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