// 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_ChangeFeed_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 ChangeFeed via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForChangeFeed, ChangeFeedGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ChangeFeedGenerator returns a generator of ChangeFeed instances for property testing.
func ChangeFeedGenerator() gopter.Gen {
	if changeFeedGenerator != nil {
		return changeFeedGenerator
	}

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

	return changeFeedGenerator
}

// AddIndependentPropertyGeneratorsForChangeFeed is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForChangeFeed(gens map[string]gopter.Gen) {
	gens["Enabled"] = gen.PtrOf(gen.Bool())
	gens["RetentionInDays"] = gen.PtrOf(gen.Int())
}

func Test_CorsRule_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 CorsRule via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCorsRule, CorsRuleGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// CorsRuleGenerator returns a generator of CorsRule instances for property testing.
func CorsRuleGenerator() gopter.Gen {
	if corsRuleGenerator != nil {
		return corsRuleGenerator
	}

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

	return corsRuleGenerator
}

// AddIndependentPropertyGeneratorsForCorsRule is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForCorsRule(gens map[string]gopter.Gen) {
	gens["AllowedHeaders"] = gen.SliceOf(gen.AlphaString())
	gens["AllowedMethods"] = gen.SliceOf(gen.OneConstOf(
		CorsRule_AllowedMethods_DELETE,
		CorsRule_AllowedMethods_GET,
		CorsRule_AllowedMethods_HEAD,
		CorsRule_AllowedMethods_MERGE,
		CorsRule_AllowedMethods_OPTIONS,
		CorsRule_AllowedMethods_PATCH,
		CorsRule_AllowedMethods_POST,
		CorsRule_AllowedMethods_PUT))
	gens["AllowedOrigins"] = gen.SliceOf(gen.AlphaString())
	gens["ExposedHeaders"] = gen.SliceOf(gen.AlphaString())
	gens["MaxAgeInSeconds"] = gen.PtrOf(gen.Int())
}

func Test_CorsRules_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 CorsRules via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForCorsRules, CorsRulesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// CorsRulesGenerator returns a generator of CorsRules instances for property testing.
func CorsRulesGenerator() gopter.Gen {
	if corsRulesGenerator != nil {
		return corsRulesGenerator
	}

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

	return corsRulesGenerator
}

// AddRelatedPropertyGeneratorsForCorsRules is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForCorsRules(gens map[string]gopter.Gen) {
	gens["CorsRules"] = gen.SliceOf(CorsRuleGenerator())
}

func Test_DeleteRetentionPolicy_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 DeleteRetentionPolicy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForDeleteRetentionPolicy, DeleteRetentionPolicyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// DeleteRetentionPolicyGenerator returns a generator of DeleteRetentionPolicy instances for property testing.
func DeleteRetentionPolicyGenerator() gopter.Gen {
	if deleteRetentionPolicyGenerator != nil {
		return deleteRetentionPolicyGenerator
	}

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

	return deleteRetentionPolicyGenerator
}

// AddIndependentPropertyGeneratorsForDeleteRetentionPolicy is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForDeleteRetentionPolicy(gens map[string]gopter.Gen) {
	gens["AllowPermanentDelete"] = gen.PtrOf(gen.Bool())
	gens["Days"] = gen.PtrOf(gen.Int())
	gens["Enabled"] = gen.PtrOf(gen.Bool())
}

func Test_LastAccessTimeTrackingPolicy_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 LastAccessTimeTrackingPolicy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForLastAccessTimeTrackingPolicy, LastAccessTimeTrackingPolicyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// LastAccessTimeTrackingPolicyGenerator returns a generator of LastAccessTimeTrackingPolicy instances for property testing.
func LastAccessTimeTrackingPolicyGenerator() gopter.Gen {
	if lastAccessTimeTrackingPolicyGenerator != nil {
		return lastAccessTimeTrackingPolicyGenerator
	}

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

	return lastAccessTimeTrackingPolicyGenerator
}

// AddIndependentPropertyGeneratorsForLastAccessTimeTrackingPolicy is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForLastAccessTimeTrackingPolicy(gens map[string]gopter.Gen) {
	gens["BlobType"] = gen.SliceOf(gen.AlphaString())
	gens["Enable"] = gen.PtrOf(gen.Bool())
	gens["Name"] = gen.PtrOf(gen.OneConstOf(LastAccessTimeTrackingPolicy_Name_AccessTimeTracking))
	gens["TrackingGranularityInDays"] = gen.PtrOf(gen.Int())
}

func Test_RestorePolicyProperties_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 RestorePolicyProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForRestorePolicyProperties, RestorePolicyPropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// RestorePolicyPropertiesGenerator returns a generator of RestorePolicyProperties instances for property testing.
func RestorePolicyPropertiesGenerator() gopter.Gen {
	if restorePolicyPropertiesGenerator != nil {
		return restorePolicyPropertiesGenerator
	}

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

	return restorePolicyPropertiesGenerator
}

// AddIndependentPropertyGeneratorsForRestorePolicyProperties is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForRestorePolicyProperties(gens map[string]gopter.Gen) {
	gens["Days"] = gen.PtrOf(gen.Int())
	gens["Enabled"] = gen.PtrOf(gen.Bool())
}

func Test_StorageAccountsBlobService_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 StorageAccountsBlobService_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsBlobService_Spec, StorageAccountsBlobService_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccountsBlobService_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 StorageAccountsBlobService_Spec instances for property testing - lazily instantiated by
// StorageAccountsBlobService_SpecGenerator()
var storageAccountsBlobService_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStorageAccountsBlobService_Spec(generators)
	AddRelatedPropertyGeneratorsForStorageAccountsBlobService_Spec(generators)
	storageAccountsBlobService_SpecGenerator = gen.Struct(reflect.TypeOf(StorageAccountsBlobService_Spec{}), generators)

	return storageAccountsBlobService_SpecGenerator
}

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

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

func Test_StorageAccounts_BlobService_Properties_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 StorageAccounts_BlobService_Properties_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccounts_BlobService_Properties_Spec, StorageAccounts_BlobService_Properties_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccounts_BlobService_Properties_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 StorageAccounts_BlobService_Properties_Spec instances for property testing - lazily instantiated by
// StorageAccounts_BlobService_Properties_SpecGenerator()
var storageAccounts_BlobService_Properties_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec(generators)
	AddRelatedPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec(generators)
	storageAccounts_BlobService_Properties_SpecGenerator = gen.Struct(reflect.TypeOf(StorageAccounts_BlobService_Properties_Spec{}), generators)

	return storageAccounts_BlobService_Properties_SpecGenerator
}

// AddIndependentPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec(gens map[string]gopter.Gen) {
	gens["AutomaticSnapshotPolicyEnabled"] = gen.PtrOf(gen.Bool())
	gens["DefaultServiceVersion"] = gen.PtrOf(gen.AlphaString())
	gens["IsVersioningEnabled"] = gen.PtrOf(gen.Bool())
}

// AddRelatedPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForStorageAccounts_BlobService_Properties_Spec(gens map[string]gopter.Gen) {
	gens["ChangeFeed"] = gen.PtrOf(ChangeFeedGenerator())
	gens["ContainerDeleteRetentionPolicy"] = gen.PtrOf(DeleteRetentionPolicyGenerator())
	gens["Cors"] = gen.PtrOf(CorsRulesGenerator())
	gens["DeleteRetentionPolicy"] = gen.PtrOf(DeleteRetentionPolicyGenerator())
	gens["LastAccessTimeTrackingPolicy"] = gen.PtrOf(LastAccessTimeTrackingPolicyGenerator())
	gens["RestorePolicy"] = gen.PtrOf(RestorePolicyPropertiesGenerator())
}
