// 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_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 FleetHubProfile_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetHubProfile_STATUS, FleetHubProfile_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FleetHubProfile_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 FleetHubProfile_STATUS instances for property testing - lazily instantiated by
// FleetHubProfile_STATUSGenerator()
var fleetHubProfile_STATUSGenerator gopter.Gen

// FleetHubProfile_STATUSGenerator returns a generator of FleetHubProfile_STATUS instances for property testing.
func FleetHubProfile_STATUSGenerator() gopter.Gen {
	if fleetHubProfile_STATUSGenerator != nil {
		return fleetHubProfile_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetHubProfile_STATUS(generators)
	fleetHubProfile_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetHubProfile_STATUS{}), generators)

	return fleetHubProfile_STATUSGenerator
}

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

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

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

	// Deserialize back into memory
	var actual FleetProperties_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 FleetProperties_STATUS instances for property testing - lazily instantiated by
// FleetProperties_STATUSGenerator()
var fleetProperties_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetProperties_STATUS(generators)
	fleetProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetProperties_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetProperties_STATUS(generators)
	AddRelatedPropertyGeneratorsForFleetProperties_STATUS(generators)
	fleetProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetProperties_STATUS{}), generators)

	return fleetProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForFleetProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFleetProperties_STATUS(gens map[string]gopter.Gen) {
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		FleetProvisioningState_STATUS_Canceled,
		FleetProvisioningState_STATUS_Creating,
		FleetProvisioningState_STATUS_Deleting,
		FleetProvisioningState_STATUS_Failed,
		FleetProvisioningState_STATUS_Succeeded,
		FleetProvisioningState_STATUS_Updating))
}

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

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

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleet_STATUS(generators)
	fleet_STATUSGenerator = gen.Struct(reflect.TypeOf(Fleet_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleet_STATUS(generators)
	AddRelatedPropertyGeneratorsForFleet_STATUS(generators)
	fleet_STATUSGenerator = gen.Struct(reflect.TypeOf(Fleet_STATUS{}), generators)

	return fleet_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForFleet_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFleet_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())
}

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

func Test_SystemData_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 SystemData_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSystemData_STATUS, SystemData_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual SystemData_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 SystemData_STATUS instances for property testing - lazily instantiated by SystemData_STATUSGenerator()
var systemData_STATUSGenerator gopter.Gen

// SystemData_STATUSGenerator returns a generator of SystemData_STATUS instances for property testing.
func SystemData_STATUSGenerator() gopter.Gen {
	if systemData_STATUSGenerator != nil {
		return systemData_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSystemData_STATUS(generators)
	systemData_STATUSGenerator = gen.Struct(reflect.TypeOf(SystemData_STATUS{}), generators)

	return systemData_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForSystemData_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSystemData_STATUS(gens map[string]gopter.Gen) {
	gens["CreatedAt"] = gen.PtrOf(gen.AlphaString())
	gens["CreatedBy"] = gen.PtrOf(gen.AlphaString())
	gens["CreatedByType"] = gen.PtrOf(gen.OneConstOf(
		SystemData_CreatedByType_STATUS_Application,
		SystemData_CreatedByType_STATUS_Key,
		SystemData_CreatedByType_STATUS_ManagedIdentity,
		SystemData_CreatedByType_STATUS_User))
	gens["LastModifiedAt"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedBy"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedByType"] = gen.PtrOf(gen.OneConstOf(
		SystemData_LastModifiedByType_STATUS_Application,
		SystemData_LastModifiedByType_STATUS_Key,
		SystemData_LastModifiedByType_STATUS_ManagedIdentity,
		SystemData_LastModifiedByType_STATUS_User))
}
