// 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_Subscription_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 Subscription via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSubscription, SubscriptionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// SubscriptionGenerator returns a generator of Subscription instances for property testing.
func SubscriptionGenerator() gopter.Gen {
	if subscriptionGenerator != nil {
		return subscriptionGenerator
	}

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

	return subscriptionGenerator
}

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

func Test_SubscriptionOperatorSecrets_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 SubscriptionOperatorSecrets via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSubscriptionOperatorSecrets, SubscriptionOperatorSecretsGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// SubscriptionOperatorSecretsGenerator returns a generator of SubscriptionOperatorSecrets instances for property testing.
func SubscriptionOperatorSecretsGenerator() gopter.Gen {
	if subscriptionOperatorSecretsGenerator != nil {
		return subscriptionOperatorSecretsGenerator
	}

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

	return subscriptionOperatorSecretsGenerator
}

func Test_SubscriptionOperatorSpec_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 SubscriptionOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSubscriptionOperatorSpec, SubscriptionOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// SubscriptionOperatorSpecGenerator returns a generator of SubscriptionOperatorSpec instances for property testing.
func SubscriptionOperatorSpecGenerator() gopter.Gen {
	if subscriptionOperatorSpecGenerator != nil {
		return subscriptionOperatorSpecGenerator
	}

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

	return subscriptionOperatorSpecGenerator
}

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

func Test_Subscription_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 Subscription_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSubscription_STATUS, Subscription_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Subscription_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 Subscription_STATUS instances for property testing - lazily instantiated by
// Subscription_STATUSGenerator()
var subscription_STATUSGenerator gopter.Gen

// Subscription_STATUSGenerator returns a generator of Subscription_STATUS instances for property testing.
func Subscription_STATUSGenerator() gopter.Gen {
	if subscription_STATUSGenerator != nil {
		return subscription_STATUSGenerator
	}

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

	return subscription_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForSubscription_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSubscription_STATUS(gens map[string]gopter.Gen) {
	gens["AllowTracing"] = gen.PtrOf(gen.Bool())
	gens["CreatedDate"] = gen.PtrOf(gen.AlphaString())
	gens["DisplayName"] = gen.PtrOf(gen.AlphaString())
	gens["EndDate"] = gen.PtrOf(gen.AlphaString())
	gens["ExpirationDate"] = gen.PtrOf(gen.AlphaString())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["NotificationDate"] = gen.PtrOf(gen.AlphaString())
	gens["OwnerId"] = gen.PtrOf(gen.AlphaString())
	gens["Scope"] = gen.PtrOf(gen.AlphaString())
	gens["StartDate"] = gen.PtrOf(gen.AlphaString())
	gens["State"] = gen.PtrOf(gen.AlphaString())
	gens["StateComment"] = gen.PtrOf(gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
}

func Test_Subscription_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 Subscription_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSubscription_Spec, Subscription_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Subscription_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 Subscription_Spec instances for property testing - lazily instantiated by Subscription_SpecGenerator()
var subscription_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSubscription_Spec(generators)
	AddRelatedPropertyGeneratorsForSubscription_Spec(generators)
	subscription_SpecGenerator = gen.Struct(reflect.TypeOf(Subscription_Spec{}), generators)

	return subscription_SpecGenerator
}

// AddIndependentPropertyGeneratorsForSubscription_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSubscription_Spec(gens map[string]gopter.Gen) {
	gens["AllowTracing"] = gen.PtrOf(gen.Bool())
	gens["AzureName"] = gen.AlphaString()
	gens["DisplayName"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["Scope"] = gen.PtrOf(gen.AlphaString())
	gens["State"] = gen.PtrOf(gen.AlphaString())
}

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