// 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_Capability_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 Capability via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCapability, CapabilityGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// CapabilityGenerator returns a generator of Capability instances for property testing.
func CapabilityGenerator() gopter.Gen {
	if capabilityGenerator != nil {
		return capabilityGenerator
	}

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

	return capabilityGenerator
}

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

func Test_ExtendedLocation_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 ExtendedLocation via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForExtendedLocation, ExtendedLocationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ExtendedLocationGenerator returns a generator of ExtendedLocation instances for property testing.
func ExtendedLocationGenerator() gopter.Gen {
	if extendedLocationGenerator != nil {
		return extendedLocationGenerator
	}

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

	return extendedLocationGenerator
}

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

func Test_HostingEnvironmentProfile_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 HostingEnvironmentProfile via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForHostingEnvironmentProfile, HostingEnvironmentProfileGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// HostingEnvironmentProfileGenerator returns a generator of HostingEnvironmentProfile instances for property testing.
func HostingEnvironmentProfileGenerator() gopter.Gen {
	if hostingEnvironmentProfileGenerator != nil {
		return hostingEnvironmentProfileGenerator
	}

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

	return hostingEnvironmentProfileGenerator
}

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

func Test_KubeEnvironmentProfile_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 KubeEnvironmentProfile via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForKubeEnvironmentProfile, KubeEnvironmentProfileGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// KubeEnvironmentProfileGenerator returns a generator of KubeEnvironmentProfile instances for property testing.
func KubeEnvironmentProfileGenerator() gopter.Gen {
	if kubeEnvironmentProfileGenerator != nil {
		return kubeEnvironmentProfileGenerator
	}

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

	return kubeEnvironmentProfileGenerator
}

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

func Test_ServerFarm_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 ServerFarm_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServerFarm_Spec, ServerFarm_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServerFarm_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 ServerFarm_Spec instances for property testing - lazily instantiated by ServerFarm_SpecGenerator()
var serverFarm_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServerFarm_Spec(generators)
	AddRelatedPropertyGeneratorsForServerFarm_Spec(generators)
	serverFarm_SpecGenerator = gen.Struct(reflect.TypeOf(ServerFarm_Spec{}), generators)

	return serverFarm_SpecGenerator
}

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

// AddRelatedPropertyGeneratorsForServerFarm_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForServerFarm_Spec(gens map[string]gopter.Gen) {
	gens["ExtendedLocation"] = gen.PtrOf(ExtendedLocationGenerator())
	gens["Properties"] = gen.PtrOf(Serverfarm_Properties_SpecGenerator())
	gens["Sku"] = gen.PtrOf(SkuDescriptionGenerator())
}

func Test_Serverfarm_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 Serverfarm_Properties_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServerfarm_Properties_Spec, Serverfarm_Properties_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Serverfarm_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 Serverfarm_Properties_Spec instances for property testing - lazily instantiated by
// Serverfarm_Properties_SpecGenerator()
var serverfarm_Properties_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServerfarm_Properties_Spec(generators)
	AddRelatedPropertyGeneratorsForServerfarm_Properties_Spec(generators)
	serverfarm_Properties_SpecGenerator = gen.Struct(reflect.TypeOf(Serverfarm_Properties_Spec{}), generators)

	return serverfarm_Properties_SpecGenerator
}

// AddIndependentPropertyGeneratorsForServerfarm_Properties_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForServerfarm_Properties_Spec(gens map[string]gopter.Gen) {
	gens["ElasticScaleEnabled"] = gen.PtrOf(gen.Bool())
	gens["FreeOfferExpirationTime"] = gen.PtrOf(gen.AlphaString())
	gens["HyperV"] = gen.PtrOf(gen.Bool())
	gens["IsSpot"] = gen.PtrOf(gen.Bool())
	gens["IsXenon"] = gen.PtrOf(gen.Bool())
	gens["MaximumElasticWorkerCount"] = gen.PtrOf(gen.Int())
	gens["PerSiteScaling"] = gen.PtrOf(gen.Bool())
	gens["Reserved"] = gen.PtrOf(gen.Bool())
	gens["SpotExpirationTime"] = gen.PtrOf(gen.AlphaString())
	gens["TargetWorkerCount"] = gen.PtrOf(gen.Int())
	gens["TargetWorkerSizeId"] = gen.PtrOf(gen.Int())
	gens["WorkerTierName"] = gen.PtrOf(gen.AlphaString())
	gens["ZoneRedundant"] = gen.PtrOf(gen.Bool())
}

// AddRelatedPropertyGeneratorsForServerfarm_Properties_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForServerfarm_Properties_Spec(gens map[string]gopter.Gen) {
	gens["HostingEnvironmentProfile"] = gen.PtrOf(HostingEnvironmentProfileGenerator())
	gens["KubeEnvironmentProfile"] = gen.PtrOf(KubeEnvironmentProfileGenerator())
}

func Test_SkuCapacity_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 SkuCapacity via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSkuCapacity, SkuCapacityGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// SkuCapacityGenerator returns a generator of SkuCapacity instances for property testing.
func SkuCapacityGenerator() gopter.Gen {
	if skuCapacityGenerator != nil {
		return skuCapacityGenerator
	}

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

	return skuCapacityGenerator
}

// AddIndependentPropertyGeneratorsForSkuCapacity is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSkuCapacity(gens map[string]gopter.Gen) {
	gens["Default"] = gen.PtrOf(gen.Int())
	gens["ElasticMaximum"] = gen.PtrOf(gen.Int())
	gens["Maximum"] = gen.PtrOf(gen.Int())
	gens["Minimum"] = gen.PtrOf(gen.Int())
	gens["ScaleType"] = gen.PtrOf(gen.AlphaString())
}

func Test_SkuDescription_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 SkuDescription via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSkuDescription, SkuDescriptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSkuDescription(generators)
	AddRelatedPropertyGeneratorsForSkuDescription(generators)
	skuDescriptionGenerator = gen.Struct(reflect.TypeOf(SkuDescription{}), generators)

	return skuDescriptionGenerator
}

// AddIndependentPropertyGeneratorsForSkuDescription is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSkuDescription(gens map[string]gopter.Gen) {
	gens["Capacity"] = gen.PtrOf(gen.Int())
	gens["Family"] = gen.PtrOf(gen.AlphaString())
	gens["Locations"] = gen.SliceOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["Size"] = gen.PtrOf(gen.AlphaString())
	gens["Tier"] = gen.PtrOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForSkuDescription is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForSkuDescription(gens map[string]gopter.Gen) {
	gens["Capabilities"] = gen.SliceOf(CapabilityGenerator())
	gens["SkuCapacity"] = gen.PtrOf(SkuCapacityGenerator())
}
