// 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_FleetHubProfile_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 FleetHubProfile via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetHubProfile, FleetHubProfileGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// FleetHubProfileGenerator returns a generator of FleetHubProfile instances for property testing.
func FleetHubProfileGenerator() gopter.Gen {
	if fleetHubProfileGenerator != nil {
		return fleetHubProfileGenerator
	}

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

	return fleetHubProfileGenerator
}

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

func Test_FleetProperties_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 FleetProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetProperties, FleetPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// FleetPropertiesGenerator returns a generator of FleetProperties instances for property testing.
func FleetPropertiesGenerator() gopter.Gen {
	if fleetPropertiesGenerator != nil {
		return fleetPropertiesGenerator
	}

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

	return fleetPropertiesGenerator
}

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

func Test_Fleet_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 Fleet_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleet_Spec, Fleet_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Fleet_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 Fleet_Spec instances for property testing - lazily instantiated by Fleet_SpecGenerator()
var fleet_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleet_Spec(generators)
	AddRelatedPropertyGeneratorsForFleet_Spec(generators)
	fleet_SpecGenerator = gen.Struct(reflect.TypeOf(Fleet_Spec{}), generators)

	return fleet_SpecGenerator
}

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

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