// 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/containerservice/v1api20240901/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_AdvancedNetworkingObservability_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from AdvancedNetworkingObservability_STATUS to AdvancedNetworkingObservability_STATUS via AssignProperties_To_AdvancedNetworkingObservability_STATUS & AssignProperties_From_AdvancedNetworkingObservability_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForAdvancedNetworkingObservability_STATUS, AdvancedNetworkingObservability_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual AdvancedNetworkingObservability_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 AdvancedNetworkingObservability_STATUS instances for property testing - lazily instantiated by
// AdvancedNetworkingObservability_STATUSGenerator()
var advancedNetworkingObservability_STATUSGenerator gopter.Gen

// AdvancedNetworkingObservability_STATUSGenerator returns a generator of AdvancedNetworkingObservability_STATUS instances for property testing.
func AdvancedNetworkingObservability_STATUSGenerator() gopter.Gen {
	if advancedNetworkingObservability_STATUSGenerator != nil {
		return advancedNetworkingObservability_STATUSGenerator
	}

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

	return advancedNetworkingObservability_STATUSGenerator
}

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

func Test_AdvancedNetworking_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from AdvancedNetworking_STATUS to AdvancedNetworking_STATUS via AssignProperties_To_AdvancedNetworking_STATUS & AssignProperties_From_AdvancedNetworking_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForAdvancedNetworking_STATUS, AdvancedNetworking_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual AdvancedNetworking_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 AdvancedNetworking_STATUS instances for property testing - lazily instantiated by
// AdvancedNetworking_STATUSGenerator()
var advancedNetworking_STATUSGenerator gopter.Gen

// AdvancedNetworking_STATUSGenerator returns a generator of AdvancedNetworking_STATUS instances for property testing.
func AdvancedNetworking_STATUSGenerator() gopter.Gen {
	if advancedNetworking_STATUSGenerator != nil {
		return advancedNetworking_STATUSGenerator
	}

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

	return advancedNetworking_STATUSGenerator
}

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