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

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20240501/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_BackendCircuitBreaker_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from BackendCircuitBreaker_STATUS to BackendCircuitBreaker_STATUS via AssignProperties_To_BackendCircuitBreaker_STATUS & AssignProperties_From_BackendCircuitBreaker_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForBackendCircuitBreaker_STATUS, BackendCircuitBreaker_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual BackendCircuitBreaker_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 BackendCircuitBreaker_STATUS instances for property testing - lazily instantiated by
// BackendCircuitBreaker_STATUSGenerator()
var backendCircuitBreaker_STATUSGenerator gopter.Gen

// BackendCircuitBreaker_STATUSGenerator returns a generator of BackendCircuitBreaker_STATUS instances for property testing.
func BackendCircuitBreaker_STATUSGenerator() gopter.Gen {
	if backendCircuitBreaker_STATUSGenerator != nil {
		return backendCircuitBreaker_STATUSGenerator
	}

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

	return backendCircuitBreaker_STATUSGenerator
}

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

func Test_CircuitBreakerFailureCondition_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from CircuitBreakerFailureCondition_STATUS to CircuitBreakerFailureCondition_STATUS via AssignProperties_To_CircuitBreakerFailureCondition_STATUS & AssignProperties_From_CircuitBreakerFailureCondition_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForCircuitBreakerFailureCondition_STATUS, CircuitBreakerFailureCondition_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual CircuitBreakerFailureCondition_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 CircuitBreakerFailureCondition_STATUS instances for property testing - lazily instantiated by
// CircuitBreakerFailureCondition_STATUSGenerator()
var circuitBreakerFailureCondition_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForCircuitBreakerFailureCondition_STATUS(generators)
	AddRelatedPropertyGeneratorsForCircuitBreakerFailureCondition_STATUS(generators)
	circuitBreakerFailureCondition_STATUSGenerator = gen.Struct(reflect.TypeOf(CircuitBreakerFailureCondition_STATUS{}), generators)

	return circuitBreakerFailureCondition_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForCircuitBreakerFailureCondition_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForCircuitBreakerFailureCondition_STATUS(gens map[string]gopter.Gen) {
	gens["Count"] = gen.PtrOf(gen.Int())
	gens["ErrorReasons"] = gen.SliceOf(gen.AlphaString())
	gens["Interval"] = gen.PtrOf(gen.AlphaString())
	gens["Percentage"] = gen.PtrOf(gen.Int())
}

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

func Test_CircuitBreakerRule_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from CircuitBreakerRule_STATUS to CircuitBreakerRule_STATUS via AssignProperties_To_CircuitBreakerRule_STATUS & AssignProperties_From_CircuitBreakerRule_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForCircuitBreakerRule_STATUS, CircuitBreakerRule_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual CircuitBreakerRule_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 CircuitBreakerRule_STATUS instances for property testing - lazily instantiated by
// CircuitBreakerRule_STATUSGenerator()
var circuitBreakerRule_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForCircuitBreakerRule_STATUS(generators)
	AddRelatedPropertyGeneratorsForCircuitBreakerRule_STATUS(generators)
	circuitBreakerRule_STATUSGenerator = gen.Struct(reflect.TypeOf(CircuitBreakerRule_STATUS{}), generators)

	return circuitBreakerRule_STATUSGenerator
}

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

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

func Test_FailureStatusCodeRange_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from FailureStatusCodeRange_STATUS to FailureStatusCodeRange_STATUS via AssignProperties_To_FailureStatusCodeRange_STATUS & AssignProperties_From_FailureStatusCodeRange_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForFailureStatusCodeRange_STATUS, FailureStatusCodeRange_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual FailureStatusCodeRange_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 FailureStatusCodeRange_STATUS instances for property testing - lazily instantiated by
// FailureStatusCodeRange_STATUSGenerator()
var failureStatusCodeRange_STATUSGenerator gopter.Gen

// FailureStatusCodeRange_STATUSGenerator returns a generator of FailureStatusCodeRange_STATUS instances for property testing.
func FailureStatusCodeRange_STATUSGenerator() gopter.Gen {
	if failureStatusCodeRange_STATUSGenerator != nil {
		return failureStatusCodeRange_STATUSGenerator
	}

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

	return failureStatusCodeRange_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForFailureStatusCodeRange_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForFailureStatusCodeRange_STATUS(gens map[string]gopter.Gen) {
	gens["Max"] = gen.PtrOf(gen.Int())
	gens["Min"] = gen.PtrOf(gen.Int())
}
