// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package storage

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_FlexibleServersVirtualEndpoint_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MinSuccessfulTests = 20
	parameters.MaxSize = 3
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip of FlexibleServersVirtualEndpoint via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFlexibleServersVirtualEndpoint, FlexibleServersVirtualEndpointGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// FlexibleServersVirtualEndpointGenerator returns a generator of FlexibleServersVirtualEndpoint instances for property testing.
func FlexibleServersVirtualEndpointGenerator() gopter.Gen {
	if flexibleServersVirtualEndpointGenerator != nil {
		return flexibleServersVirtualEndpointGenerator
	}

	generators := make(map[string]gopter.Gen)
	AddRelatedPropertyGeneratorsForFlexibleServersVirtualEndpoint(generators)
	flexibleServersVirtualEndpointGenerator = gen.Struct(reflect.TypeOf(FlexibleServersVirtualEndpoint{}), generators)

	return flexibleServersVirtualEndpointGenerator
}

// AddRelatedPropertyGeneratorsForFlexibleServersVirtualEndpoint is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForFlexibleServersVirtualEndpoint(gens map[string]gopter.Gen) {
	gens["Spec"] = FlexibleServersVirtualEndpoint_SpecGenerator()
	gens["Status"] = FlexibleServersVirtualEndpoint_STATUSGenerator()
}

func Test_FlexibleServersVirtualEndpointOperatorSpec_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 FlexibleServersVirtualEndpointOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFlexibleServersVirtualEndpointOperatorSpec, FlexibleServersVirtualEndpointOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// FlexibleServersVirtualEndpointOperatorSpecGenerator returns a generator of FlexibleServersVirtualEndpointOperatorSpec instances for property testing.
func FlexibleServersVirtualEndpointOperatorSpecGenerator() gopter.Gen {
	if flexibleServersVirtualEndpointOperatorSpecGenerator != nil {
		return flexibleServersVirtualEndpointOperatorSpecGenerator
	}

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

	return flexibleServersVirtualEndpointOperatorSpecGenerator
}

func Test_FlexibleServersVirtualEndpoint_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 FlexibleServersVirtualEndpoint_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFlexibleServersVirtualEndpoint_STATUS, FlexibleServersVirtualEndpoint_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FlexibleServersVirtualEndpoint_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 FlexibleServersVirtualEndpoint_STATUS instances for property testing - lazily instantiated by
// FlexibleServersVirtualEndpoint_STATUSGenerator()
var flexibleServersVirtualEndpoint_STATUSGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_STATUS(generators)
	flexibleServersVirtualEndpoint_STATUSGenerator = gen.Struct(reflect.TypeOf(FlexibleServersVirtualEndpoint_STATUS{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_STATUS(generators)
	AddRelatedPropertyGeneratorsForFlexibleServersVirtualEndpoint_STATUS(generators)
	flexibleServersVirtualEndpoint_STATUSGenerator = gen.Struct(reflect.TypeOf(FlexibleServersVirtualEndpoint_STATUS{}), generators)

	return flexibleServersVirtualEndpoint_STATUSGenerator
}

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

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

func Test_FlexibleServersVirtualEndpoint_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 FlexibleServersVirtualEndpoint_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForFlexibleServersVirtualEndpoint_Spec, FlexibleServersVirtualEndpoint_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual FlexibleServersVirtualEndpoint_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 FlexibleServersVirtualEndpoint_Spec instances for property testing - lazily instantiated by
// FlexibleServersVirtualEndpoint_SpecGenerator()
var flexibleServersVirtualEndpoint_SpecGenerator gopter.Gen

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

	generators := make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_Spec(generators)
	flexibleServersVirtualEndpoint_SpecGenerator = gen.Struct(reflect.TypeOf(FlexibleServersVirtualEndpoint_Spec{}), generators)

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_Spec(generators)
	AddRelatedPropertyGeneratorsForFlexibleServersVirtualEndpoint_Spec(generators)
	flexibleServersVirtualEndpoint_SpecGenerator = gen.Struct(reflect.TypeOf(FlexibleServersVirtualEndpoint_Spec{}), generators)

	return flexibleServersVirtualEndpoint_SpecGenerator
}

// AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFlexibleServersVirtualEndpoint_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["EndpointType"] = gen.PtrOf(gen.AlphaString())
	gens["Members"] = gen.SliceOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
}

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