// 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_ApiVersionSet_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 ApiVersionSet via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApiVersionSet, ApiVersionSetGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ApiVersionSetGenerator returns a generator of ApiVersionSet instances for property testing.
func ApiVersionSetGenerator() gopter.Gen {
	if apiVersionSetGenerator != nil {
		return apiVersionSetGenerator
	}

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

	return apiVersionSetGenerator
}

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

func Test_ApiVersionSetOperatorSpec_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 ApiVersionSetOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApiVersionSetOperatorSpec, ApiVersionSetOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ApiVersionSetOperatorSpecGenerator returns a generator of ApiVersionSetOperatorSpec instances for property testing.
func ApiVersionSetOperatorSpecGenerator() gopter.Gen {
	if apiVersionSetOperatorSpecGenerator != nil {
		return apiVersionSetOperatorSpecGenerator
	}

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

	return apiVersionSetOperatorSpecGenerator
}

func Test_ApiVersionSet_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 ApiVersionSet_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApiVersionSet_STATUS, ApiVersionSet_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ApiVersionSet_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 ApiVersionSet_STATUS instances for property testing - lazily instantiated by
// ApiVersionSet_STATUSGenerator()
var apiVersionSet_STATUSGenerator gopter.Gen

// ApiVersionSet_STATUSGenerator returns a generator of ApiVersionSet_STATUS instances for property testing.
func ApiVersionSet_STATUSGenerator() gopter.Gen {
	if apiVersionSet_STATUSGenerator != nil {
		return apiVersionSet_STATUSGenerator
	}

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

	return apiVersionSet_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForApiVersionSet_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForApiVersionSet_STATUS(gens map[string]gopter.Gen) {
	gens["Description"] = gen.PtrOf(gen.AlphaString())
	gens["DisplayName"] = gen.PtrOf(gen.AlphaString())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
	gens["VersionHeaderName"] = gen.PtrOf(gen.AlphaString())
	gens["VersionQueryName"] = gen.PtrOf(gen.AlphaString())
	gens["VersioningScheme"] = gen.PtrOf(gen.AlphaString())
}

func Test_ApiVersionSet_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 ApiVersionSet_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApiVersionSet_Spec, ApiVersionSet_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ApiVersionSet_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 ApiVersionSet_Spec instances for property testing - lazily instantiated by ApiVersionSet_SpecGenerator()
var apiVersionSet_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForApiVersionSet_Spec(generators)
	AddRelatedPropertyGeneratorsForApiVersionSet_Spec(generators)
	apiVersionSet_SpecGenerator = gen.Struct(reflect.TypeOf(ApiVersionSet_Spec{}), generators)

	return apiVersionSet_SpecGenerator
}

// AddIndependentPropertyGeneratorsForApiVersionSet_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForApiVersionSet_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["Description"] = gen.PtrOf(gen.AlphaString())
	gens["DisplayName"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["VersionHeaderName"] = gen.PtrOf(gen.AlphaString())
	gens["VersionQueryName"] = gen.PtrOf(gen.AlphaString())
	gens["VersioningScheme"] = gen.PtrOf(gen.AlphaString())
}

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