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

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/storage/v1api20230101/storage"
	"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_StorageAccountsTableService_WhenConvertedToHub_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	parameters.MinSuccessfulTests = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from StorageAccountsTableService to hub returns original",
		prop.ForAll(RunResourceConversionTestForStorageAccountsTableService, StorageAccountsTableServiceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunResourceConversionTestForStorageAccountsTableService tests if a specific instance of StorageAccountsTableService round trips to the hub storage version and back losslessly
func RunResourceConversionTestForStorageAccountsTableService(subject StorageAccountsTableService) string {
	// Copy subject to make sure conversion doesn't modify it
	copied := subject.DeepCopy()

	// Convert to our hub version
	var hub storage.StorageAccountsTableService
	err := copied.ConvertTo(&hub)
	if err != nil {
		return err.Error()
	}

	// Convert from our hub version
	var actual StorageAccountsTableService
	err = actual.ConvertFrom(&hub)
	if err != nil {
		return err.Error()
	}

	// Compare actual with what we started with
	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 ""
}

func Test_StorageAccountsTableService_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from StorageAccountsTableService to StorageAccountsTableService via AssignProperties_To_StorageAccountsTableService & AssignProperties_From_StorageAccountsTableService returns original",
		prop.ForAll(RunPropertyAssignmentTestForStorageAccountsTableService, StorageAccountsTableServiceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForStorageAccountsTableService tests if a specific instance of StorageAccountsTableService can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForStorageAccountsTableService(subject StorageAccountsTableService) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.StorageAccountsTableService
	err := copied.AssignProperties_To_StorageAccountsTableService(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual StorageAccountsTableService
	err = actual.AssignProperties_From_StorageAccountsTableService(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_StorageAccountsTableService_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 StorageAccountsTableService via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsTableService, StorageAccountsTableServiceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// StorageAccountsTableServiceGenerator returns a generator of StorageAccountsTableService instances for property testing.
func StorageAccountsTableServiceGenerator() gopter.Gen {
	if storageAccountsTableServiceGenerator != nil {
		return storageAccountsTableServiceGenerator
	}

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

	return storageAccountsTableServiceGenerator
}

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

func Test_StorageAccountsTableServiceOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from StorageAccountsTableServiceOperatorSpec to StorageAccountsTableServiceOperatorSpec via AssignProperties_To_StorageAccountsTableServiceOperatorSpec & AssignProperties_From_StorageAccountsTableServiceOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForStorageAccountsTableServiceOperatorSpec, StorageAccountsTableServiceOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForStorageAccountsTableServiceOperatorSpec tests if a specific instance of StorageAccountsTableServiceOperatorSpec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForStorageAccountsTableServiceOperatorSpec(subject StorageAccountsTableServiceOperatorSpec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.StorageAccountsTableServiceOperatorSpec
	err := copied.AssignProperties_To_StorageAccountsTableServiceOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual StorageAccountsTableServiceOperatorSpec
	err = actual.AssignProperties_From_StorageAccountsTableServiceOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_StorageAccountsTableServiceOperatorSpec_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 StorageAccountsTableServiceOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsTableServiceOperatorSpec, StorageAccountsTableServiceOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// StorageAccountsTableServiceOperatorSpecGenerator returns a generator of StorageAccountsTableServiceOperatorSpec instances for property testing.
func StorageAccountsTableServiceOperatorSpecGenerator() gopter.Gen {
	if storageAccountsTableServiceOperatorSpecGenerator != nil {
		return storageAccountsTableServiceOperatorSpecGenerator
	}

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

	return storageAccountsTableServiceOperatorSpecGenerator
}

func Test_StorageAccountsTableService_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from StorageAccountsTableService_STATUS to StorageAccountsTableService_STATUS via AssignProperties_To_StorageAccountsTableService_STATUS & AssignProperties_From_StorageAccountsTableService_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForStorageAccountsTableService_STATUS, StorageAccountsTableService_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForStorageAccountsTableService_STATUS tests if a specific instance of StorageAccountsTableService_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForStorageAccountsTableService_STATUS(subject StorageAccountsTableService_STATUS) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.StorageAccountsTableService_STATUS
	err := copied.AssignProperties_To_StorageAccountsTableService_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual StorageAccountsTableService_STATUS
	err = actual.AssignProperties_From_StorageAccountsTableService_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_StorageAccountsTableService_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 StorageAccountsTableService_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsTableService_STATUS, StorageAccountsTableService_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccountsTableService_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 StorageAccountsTableService_STATUS instances for property testing - lazily instantiated by
// StorageAccountsTableService_STATUSGenerator()
var storageAccountsTableService_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStorageAccountsTableService_STATUS(generators)
	AddRelatedPropertyGeneratorsForStorageAccountsTableService_STATUS(generators)
	storageAccountsTableService_STATUSGenerator = gen.Struct(reflect.TypeOf(StorageAccountsTableService_STATUS{}), generators)

	return storageAccountsTableService_STATUSGenerator
}

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

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

func Test_StorageAccountsTableService_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from StorageAccountsTableService_Spec to StorageAccountsTableService_Spec via AssignProperties_To_StorageAccountsTableService_Spec & AssignProperties_From_StorageAccountsTableService_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForStorageAccountsTableService_Spec, StorageAccountsTableService_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForStorageAccountsTableService_Spec tests if a specific instance of StorageAccountsTableService_Spec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForStorageAccountsTableService_Spec(subject StorageAccountsTableService_Spec) string {
	// Copy subject to make sure assignment doesn't modify it
	copied := subject.DeepCopy()

	// Use AssignPropertiesTo() for the first stage of conversion
	var other storage.StorageAccountsTableService_Spec
	err := copied.AssignProperties_To_StorageAccountsTableService_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual StorageAccountsTableService_Spec
	err = actual.AssignProperties_From_StorageAccountsTableService_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Check for a match
	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 ""
}

func Test_StorageAccountsTableService_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 StorageAccountsTableService_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsTableService_Spec, StorageAccountsTableService_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccountsTableService_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 StorageAccountsTableService_Spec instances for property testing - lazily instantiated by
// StorageAccountsTableService_SpecGenerator()
var storageAccountsTableService_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStorageAccountsTableService_Spec(generators)
	AddRelatedPropertyGeneratorsForStorageAccountsTableService_Spec(generators)
	storageAccountsTableService_SpecGenerator = gen.Struct(reflect.TypeOf(StorageAccountsTableService_Spec{}), generators)

	return storageAccountsTableService_SpecGenerator
}

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

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