// 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_FleetMemberProperties_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 FleetMemberProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetMemberProperties_STATUS, FleetMemberProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FleetMemberProperties_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 FleetMemberProperties_STATUS instances for property testing - lazily instantiated by
// FleetMemberProperties_STATUSGenerator()
var fleetMemberProperties_STATUSGenerator gopter.Gen

// FleetMemberProperties_STATUSGenerator returns a generator of FleetMemberProperties_STATUS instances for property testing.
func FleetMemberProperties_STATUSGenerator() gopter.Gen {
	if fleetMemberProperties_STATUSGenerator != nil {
		return fleetMemberProperties_STATUSGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetMemberProperties_STATUS(generators)
	fleetMemberProperties_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetMemberProperties_STATUS{}), generators)

	return fleetMemberProperties_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForFleetMemberProperties_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFleetMemberProperties_STATUS(gens map[string]gopter.Gen) {
	gens["ClusterResourceId"] = gen.PtrOf(gen.AlphaString())
	gens["Group"] = gen.PtrOf(gen.AlphaString())
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		FleetMemberProvisioningState_STATUS_Canceled,
		FleetMemberProvisioningState_STATUS_Failed,
		FleetMemberProvisioningState_STATUS_Joining,
		FleetMemberProvisioningState_STATUS_Leaving,
		FleetMemberProvisioningState_STATUS_Succeeded,
		FleetMemberProvisioningState_STATUS_Updating))
}

func Test_FleetsMember_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 FleetsMember_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFleetsMember_STATUS, FleetsMember_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FleetsMember_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 FleetsMember_STATUS instances for property testing - lazily instantiated by
// FleetsMember_STATUSGenerator()
var fleetsMember_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetsMember_STATUS(generators)
	fleetsMember_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetsMember_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFleetsMember_STATUS(generators)
	AddRelatedPropertyGeneratorsForFleetsMember_STATUS(generators)
	fleetsMember_STATUSGenerator = gen.Struct(reflect.TypeOf(FleetsMember_STATUS{}), generators)

	return fleetsMember_STATUSGenerator
}

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

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