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

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/network/v1api20240101/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_ApplicationSecurityGroup_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 ApplicationSecurityGroup to hub returns original",
		prop.ForAll(RunResourceConversionTestForApplicationSecurityGroup, ApplicationSecurityGroupGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

	// Convert from our hub version
	var actual ApplicationSecurityGroup
	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_ApplicationSecurityGroup_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ApplicationSecurityGroup to ApplicationSecurityGroup via AssignProperties_To_ApplicationSecurityGroup & AssignProperties_From_ApplicationSecurityGroup returns original",
		prop.ForAll(RunPropertyAssignmentTestForApplicationSecurityGroup, ApplicationSecurityGroupGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForApplicationSecurityGroup tests if a specific instance of ApplicationSecurityGroup can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForApplicationSecurityGroup(subject ApplicationSecurityGroup) 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.ApplicationSecurityGroup
	err := copied.AssignProperties_To_ApplicationSecurityGroup(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ApplicationSecurityGroup
	err = actual.AssignProperties_From_ApplicationSecurityGroup(&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_ApplicationSecurityGroup_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 ApplicationSecurityGroup via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApplicationSecurityGroup, ApplicationSecurityGroupGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ApplicationSecurityGroupGenerator returns a generator of ApplicationSecurityGroup instances for property testing.
func ApplicationSecurityGroupGenerator() gopter.Gen {
	if applicationSecurityGroupGenerator != nil {
		return applicationSecurityGroupGenerator
	}

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

	return applicationSecurityGroupGenerator
}

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

func Test_ApplicationSecurityGroupOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ApplicationSecurityGroupOperatorSpec to ApplicationSecurityGroupOperatorSpec via AssignProperties_To_ApplicationSecurityGroupOperatorSpec & AssignProperties_From_ApplicationSecurityGroupOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForApplicationSecurityGroupOperatorSpec, ApplicationSecurityGroupOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForApplicationSecurityGroupOperatorSpec tests if a specific instance of ApplicationSecurityGroupOperatorSpec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForApplicationSecurityGroupOperatorSpec(subject ApplicationSecurityGroupOperatorSpec) 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.ApplicationSecurityGroupOperatorSpec
	err := copied.AssignProperties_To_ApplicationSecurityGroupOperatorSpec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ApplicationSecurityGroupOperatorSpec
	err = actual.AssignProperties_From_ApplicationSecurityGroupOperatorSpec(&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_ApplicationSecurityGroupOperatorSpec_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 ApplicationSecurityGroupOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApplicationSecurityGroupOperatorSpec, ApplicationSecurityGroupOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ApplicationSecurityGroupOperatorSpecGenerator returns a generator of ApplicationSecurityGroupOperatorSpec instances for property testing.
func ApplicationSecurityGroupOperatorSpecGenerator() gopter.Gen {
	if applicationSecurityGroupOperatorSpecGenerator != nil {
		return applicationSecurityGroupOperatorSpecGenerator
	}

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

	return applicationSecurityGroupOperatorSpecGenerator
}

func Test_ApplicationSecurityGroup_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ApplicationSecurityGroup_STATUS to ApplicationSecurityGroup_STATUS via AssignProperties_To_ApplicationSecurityGroup_STATUS & AssignProperties_From_ApplicationSecurityGroup_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForApplicationSecurityGroup_STATUS, ApplicationSecurityGroup_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForApplicationSecurityGroup_STATUS tests if a specific instance of ApplicationSecurityGroup_STATUS can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForApplicationSecurityGroup_STATUS(subject ApplicationSecurityGroup_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.ApplicationSecurityGroup_STATUS
	err := copied.AssignProperties_To_ApplicationSecurityGroup_STATUS(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ApplicationSecurityGroup_STATUS
	err = actual.AssignProperties_From_ApplicationSecurityGroup_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_ApplicationSecurityGroup_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 ApplicationSecurityGroup_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApplicationSecurityGroup_STATUS, ApplicationSecurityGroup_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ApplicationSecurityGroup_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 ApplicationSecurityGroup_STATUS instances for property testing - lazily instantiated by
// ApplicationSecurityGroup_STATUSGenerator()
var applicationSecurityGroup_STATUSGenerator gopter.Gen

// ApplicationSecurityGroup_STATUSGenerator returns a generator of ApplicationSecurityGroup_STATUS instances for property testing.
func ApplicationSecurityGroup_STATUSGenerator() gopter.Gen {
	if applicationSecurityGroup_STATUSGenerator != nil {
		return applicationSecurityGroup_STATUSGenerator
	}

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

	return applicationSecurityGroup_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForApplicationSecurityGroup_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForApplicationSecurityGroup_STATUS(gens map[string]gopter.Gen) {
	gens["Etag"] = gen.PtrOf(gen.AlphaString())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["ProvisioningState"] = gen.PtrOf(gen.OneConstOf(
		ProvisioningState_STATUS_Deleting,
		ProvisioningState_STATUS_Failed,
		ProvisioningState_STATUS_Succeeded,
		ProvisioningState_STATUS_Updating))
	gens["ResourceGuid"] = gen.PtrOf(gen.AlphaString())
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
}

func Test_ApplicationSecurityGroup_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from ApplicationSecurityGroup_Spec to ApplicationSecurityGroup_Spec via AssignProperties_To_ApplicationSecurityGroup_Spec & AssignProperties_From_ApplicationSecurityGroup_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForApplicationSecurityGroup_Spec, ApplicationSecurityGroup_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

// RunPropertyAssignmentTestForApplicationSecurityGroup_Spec tests if a specific instance of ApplicationSecurityGroup_Spec can be assigned to storage and back losslessly
func RunPropertyAssignmentTestForApplicationSecurityGroup_Spec(subject ApplicationSecurityGroup_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.ApplicationSecurityGroup_Spec
	err := copied.AssignProperties_To_ApplicationSecurityGroup_Spec(&other)
	if err != nil {
		return err.Error()
	}

	// Use AssignPropertiesFrom() to convert back to our original type
	var actual ApplicationSecurityGroup_Spec
	err = actual.AssignProperties_From_ApplicationSecurityGroup_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_ApplicationSecurityGroup_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 ApplicationSecurityGroup_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApplicationSecurityGroup_Spec, ApplicationSecurityGroup_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ApplicationSecurityGroup_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 ApplicationSecurityGroup_Spec instances for property testing - lazily instantiated by
// ApplicationSecurityGroup_SpecGenerator()
var applicationSecurityGroup_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForApplicationSecurityGroup_Spec(generators)
	AddRelatedPropertyGeneratorsForApplicationSecurityGroup_Spec(generators)
	applicationSecurityGroup_SpecGenerator = gen.Struct(reflect.TypeOf(ApplicationSecurityGroup_Spec{}), generators)

	return applicationSecurityGroup_SpecGenerator
}

// AddIndependentPropertyGeneratorsForApplicationSecurityGroup_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForApplicationSecurityGroup_Spec(gens map[string]gopter.Gen) {
	gens["AzureName"] = gen.AlphaString()
	gens["Location"] = gen.PtrOf(gen.AlphaString())
	gens["Tags"] = gen.MapOf(
		gen.AlphaString(),
		gen.AlphaString())
}

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