// 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/managedidentity/v1api20230131/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_FederatedIdentityCredential_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 FederatedIdentityCredential to hub returns original",
		prop.ForAll(RunResourceConversionTestForFederatedIdentityCredential, FederatedIdentityCredentialGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

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

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

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

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

// FederatedIdentityCredentialGenerator returns a generator of FederatedIdentityCredential instances for property testing.
func FederatedIdentityCredentialGenerator() gopter.Gen {
	if federatedIdentityCredentialGenerator != nil {
		return federatedIdentityCredentialGenerator
	}

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

	return federatedIdentityCredentialGenerator
}

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

func Test_FederatedIdentityCredentialOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from FederatedIdentityCredentialOperatorSpec to FederatedIdentityCredentialOperatorSpec via AssignProperties_To_FederatedIdentityCredentialOperatorSpec & AssignProperties_From_FederatedIdentityCredentialOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForFederatedIdentityCredentialOperatorSpec, FederatedIdentityCredentialOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

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

// FederatedIdentityCredentialOperatorSpecGenerator returns a generator of FederatedIdentityCredentialOperatorSpec instances for property testing.
func FederatedIdentityCredentialOperatorSpecGenerator() gopter.Gen {
	if federatedIdentityCredentialOperatorSpecGenerator != nil {
		return federatedIdentityCredentialOperatorSpecGenerator
	}

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

	return federatedIdentityCredentialOperatorSpecGenerator
}

func Test_FederatedIdentityCredential_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from FederatedIdentityCredential_STATUS to FederatedIdentityCredential_STATUS via AssignProperties_To_FederatedIdentityCredential_STATUS & AssignProperties_From_FederatedIdentityCredential_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForFederatedIdentityCredential_STATUS, FederatedIdentityCredential_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual FederatedIdentityCredential_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 FederatedIdentityCredential_STATUS instances for property testing - lazily instantiated by
// FederatedIdentityCredential_STATUSGenerator()
var federatedIdentityCredential_STATUSGenerator gopter.Gen

// FederatedIdentityCredential_STATUSGenerator returns a generator of FederatedIdentityCredential_STATUS instances for property testing.
func FederatedIdentityCredential_STATUSGenerator() gopter.Gen {
	if federatedIdentityCredential_STATUSGenerator != nil {
		return federatedIdentityCredential_STATUSGenerator
	}

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

	return federatedIdentityCredential_STATUSGenerator
}

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

func Test_FederatedIdentityCredential_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from FederatedIdentityCredential_Spec to FederatedIdentityCredential_Spec via AssignProperties_To_FederatedIdentityCredential_Spec & AssignProperties_From_FederatedIdentityCredential_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForFederatedIdentityCredential_Spec, FederatedIdentityCredential_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual FederatedIdentityCredential_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 FederatedIdentityCredential_Spec instances for property testing - lazily instantiated by
// FederatedIdentityCredential_SpecGenerator()
var federatedIdentityCredential_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForFederatedIdentityCredential_Spec(generators)
	AddRelatedPropertyGeneratorsForFederatedIdentityCredential_Spec(generators)
	federatedIdentityCredential_SpecGenerator = gen.Struct(reflect.TypeOf(FederatedIdentityCredential_Spec{}), generators)

	return federatedIdentityCredential_SpecGenerator
}

// AddIndependentPropertyGeneratorsForFederatedIdentityCredential_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFederatedIdentityCredential_Spec(gens map[string]gopter.Gen) {
	gens["Audiences"] = gen.SliceOf(gen.AlphaString())
	gens["AzureName"] = gen.AlphaString()
	gens["Issuer"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["Subject"] = gen.PtrOf(gen.AlphaString())
}

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