// 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_CustomCertificate_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 CustomCertificate via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCustomCertificate, CustomCertificateGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// CustomCertificateGenerator returns a generator of CustomCertificate instances for property testing.
func CustomCertificateGenerator() gopter.Gen {
	if customCertificateGenerator != nil {
		return customCertificateGenerator
	}

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

	return customCertificateGenerator
}

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

func Test_CustomCertificateOperatorSpec_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 CustomCertificateOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCustomCertificateOperatorSpec, CustomCertificateOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// CustomCertificateOperatorSpecGenerator returns a generator of CustomCertificateOperatorSpec instances for property testing.
func CustomCertificateOperatorSpecGenerator() gopter.Gen {
	if customCertificateOperatorSpecGenerator != nil {
		return customCertificateOperatorSpecGenerator
	}

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

	return customCertificateOperatorSpecGenerator
}

func Test_CustomCertificate_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 CustomCertificate_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCustomCertificate_STATUS, CustomCertificate_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual CustomCertificate_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 CustomCertificate_STATUS instances for property testing - lazily instantiated by
// CustomCertificate_STATUSGenerator()
var customCertificate_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForCustomCertificate_STATUS(generators)
	AddRelatedPropertyGeneratorsForCustomCertificate_STATUS(generators)
	customCertificate_STATUSGenerator = gen.Struct(reflect.TypeOf(CustomCertificate_STATUS{}), generators)

	return customCertificate_STATUSGenerator
}

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

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

func Test_CustomCertificate_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 CustomCertificate_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCustomCertificate_Spec, CustomCertificate_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual CustomCertificate_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 CustomCertificate_Spec instances for property testing - lazily instantiated by
// CustomCertificate_SpecGenerator()
var customCertificate_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForCustomCertificate_Spec(generators)
	AddRelatedPropertyGeneratorsForCustomCertificate_Spec(generators)
	customCertificate_SpecGenerator = gen.Struct(reflect.TypeOf(CustomCertificate_Spec{}), generators)

	return customCertificate_SpecGenerator
}

// AddIndependentPropertyGeneratorsForCustomCertificate_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForCustomCertificate_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["KeyVaultBaseUri"] = gen.PtrOf(gen.AlphaString())
	gens["KeyVaultSecretName"] = gen.PtrOf(gen.AlphaString())
	gens["KeyVaultSecretVersion"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
}

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

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.AlphaString())
	gens["LastModifiedAt"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedBy"] = gen.PtrOf(gen.AlphaString())
	gens["LastModifiedByType"] = gen.PtrOf(gen.AlphaString())
}
