// 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_RouteTablePropertiesFormat_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 RouteTablePropertiesFormat_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTablePropertiesFormat_STATUS, RouteTablePropertiesFormat_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RouteTablePropertiesFormat_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 RouteTablePropertiesFormat_STATUS instances for property testing - lazily instantiated by
// RouteTablePropertiesFormat_STATUSGenerator()
var routeTablePropertiesFormat_STATUSGenerator gopter.Gen

// RouteTablePropertiesFormat_STATUSGenerator returns a generator of RouteTablePropertiesFormat_STATUS instances for property testing.
func RouteTablePropertiesFormat_STATUSGenerator() gopter.Gen {
	if routeTablePropertiesFormat_STATUSGenerator != nil {
		return routeTablePropertiesFormat_STATUSGenerator
	}

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

	return routeTablePropertiesFormat_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForRouteTablePropertiesFormat_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRouteTablePropertiesFormat_STATUS(gens map[string]gopter.Gen) {
	gens["DisableBgpRoutePropagation"] = gen.PtrOf(gen.Bool())
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		ProvisioningState_STATUS_Deleting,
		ProvisioningState_STATUS_Failed,
		ProvisioningState_STATUS_Succeeded,
		ProvisioningState_STATUS_Updating))
	gens["ResourceGuid"] = gen.PtrOf(gen.AlphaString())
}

func Test_RouteTable_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 RouteTable_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRouteTable_STATUS, RouteTable_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual RouteTable_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 RouteTable_STATUS instances for property testing - lazily instantiated by RouteTable_STATUSGenerator()
var routeTable_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForRouteTable_STATUS(generators)
	AddRelatedPropertyGeneratorsForRouteTable_STATUS(generators)
	routeTable_STATUSGenerator = gen.Struct(reflect.TypeOf(RouteTable_STATUS{}), generators)

	return routeTable_STATUSGenerator
}

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

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