// 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_FleetsUpdateRun_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 FleetsUpdateRun_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetsUpdateRun_Spec, FleetsUpdateRun_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FleetsUpdateRun_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 FleetsUpdateRun_Spec instances for property testing - lazily instantiated by
// FleetsUpdateRun_SpecGenerator()
var fleetsUpdateRun_SpecGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetsUpdateRun_Spec(generators)
	fleetsUpdateRun_SpecGenerator = gen.Struct(reflect.TypeOf(FleetsUpdateRun_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetsUpdateRun_Spec(generators)
	AddRelatedPropertyGeneratorsForFleetsUpdateRun_Spec(generators)
	fleetsUpdateRun_SpecGenerator = gen.Struct(reflect.TypeOf(FleetsUpdateRun_Spec{}), generators)

	return fleetsUpdateRun_SpecGenerator
}

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

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

func Test_ManagedClusterUpdate_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 ManagedClusterUpdate via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForManagedClusterUpdate, ManagedClusterUpdateGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ManagedClusterUpdateGenerator returns a generator of ManagedClusterUpdate instances for property testing.
func ManagedClusterUpdateGenerator() gopter.Gen {
	if managedClusterUpdateGenerator != nil {
		return managedClusterUpdateGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddRelatedPropertyGeneratorsForManagedClusterUpdate(generators)
	managedClusterUpdateGenerator = gen.Struct(reflect.TypeOf(ManagedClusterUpdate{}), generators)

	return managedClusterUpdateGenerator
}

// AddRelatedPropertyGeneratorsForManagedClusterUpdate is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForManagedClusterUpdate(gens map[string]gopter.Gen) {
	gens["NodeImageSelection"] = gen.PtrOf(NodeImageSelectionGenerator())
	gens["Upgrade"] = gen.PtrOf(ManagedClusterUpgradeSpecGenerator())
}

func Test_ManagedClusterUpgradeSpec_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 ManagedClusterUpgradeSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForManagedClusterUpgradeSpec, ManagedClusterUpgradeSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ManagedClusterUpgradeSpecGenerator returns a generator of ManagedClusterUpgradeSpec instances for property testing.
func ManagedClusterUpgradeSpecGenerator() gopter.Gen {
	if managedClusterUpgradeSpecGenerator != nil {
		return managedClusterUpgradeSpecGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForManagedClusterUpgradeSpec(generators)
	managedClusterUpgradeSpecGenerator = gen.Struct(reflect.TypeOf(ManagedClusterUpgradeSpec{}), generators)

	return managedClusterUpgradeSpecGenerator
}

// AddIndependentPropertyGeneratorsForManagedClusterUpgradeSpec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForManagedClusterUpgradeSpec(gens map[string]gopter.Gen) {
	gens["KubernetesVersion"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.OneConstOf(ManagedClusterUpgradeType_ControlPlaneOnly, ManagedClusterUpgradeType_Full, ManagedClusterUpgradeType_NodeImageOnly))
}

func Test_NodeImageSelection_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 NodeImageSelection via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNodeImageSelection, NodeImageSelectionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// NodeImageSelectionGenerator returns a generator of NodeImageSelection instances for property testing.
func NodeImageSelectionGenerator() gopter.Gen {
	if nodeImageSelectionGenerator != nil {
		return nodeImageSelectionGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNodeImageSelection(generators)
	nodeImageSelectionGenerator = gen.Struct(reflect.TypeOf(NodeImageSelection{}), generators)

	return nodeImageSelectionGenerator
}

// AddIndependentPropertyGeneratorsForNodeImageSelection is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForNodeImageSelection(gens map[string]gopter.Gen) {
	gens["Type"] = gen.PtrOf(gen.OneConstOf(NodeImageSelectionType_Consistent, NodeImageSelectionType_Custom, NodeImageSelectionType_Latest))
}

func Test_UpdateGroup_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 UpdateGroup via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForUpdateGroup, UpdateGroupGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// UpdateGroupGenerator returns a generator of UpdateGroup instances for property testing.
func UpdateGroupGenerator() gopter.Gen {
	if updateGroupGenerator != nil {
		return updateGroupGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForUpdateGroup(generators)
	updateGroupGenerator = gen.Struct(reflect.TypeOf(UpdateGroup{}), generators)

	return updateGroupGenerator
}

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

func Test_UpdateRunProperties_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 UpdateRunProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForUpdateRunProperties, UpdateRunPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForUpdateRunProperties(generators)
	updateRunPropertiesGenerator = gen.Struct(reflect.TypeOf(UpdateRunProperties{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForUpdateRunProperties(generators)
	AddRelatedPropertyGeneratorsForUpdateRunProperties(generators)
	updateRunPropertiesGenerator = gen.Struct(reflect.TypeOf(UpdateRunProperties{}), generators)

	return updateRunPropertiesGenerator
}

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

// AddRelatedPropertyGeneratorsForUpdateRunProperties is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForUpdateRunProperties(gens map[string]gopter.Gen) {
	gens["ManagedClusterUpdate"] = gen.PtrOf(ManagedClusterUpdateGenerator())
	gens["Strategy"] = gen.PtrOf(UpdateRunStrategyGenerator())
}

func Test_UpdateRunStrategy_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 UpdateRunStrategy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForUpdateRunStrategy, UpdateRunStrategyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// UpdateRunStrategyGenerator returns a generator of UpdateRunStrategy instances for property testing.
func UpdateRunStrategyGenerator() gopter.Gen {
	if updateRunStrategyGenerator != nil {
		return updateRunStrategyGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddRelatedPropertyGeneratorsForUpdateRunStrategy(generators)
	updateRunStrategyGenerator = gen.Struct(reflect.TypeOf(UpdateRunStrategy{}), generators)

	return updateRunStrategyGenerator
}

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

func Test_UpdateStage_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 UpdateStage via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForUpdateStage, UpdateStageGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForUpdateStage(generators)
	updateStageGenerator = gen.Struct(reflect.TypeOf(UpdateStage{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForUpdateStage(generators)
	AddRelatedPropertyGeneratorsForUpdateStage(generators)
	updateStageGenerator = gen.Struct(reflect.TypeOf(UpdateStage{}), generators)

	return updateStageGenerator
}

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

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