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

import (
	"encoding/json"
	storage "github.com/Azure/azure-service-operator/v2/api/insights/v1api20171001/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_PricingPlan_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 PricingPlan to hub returns original",
		prop.ForAll(RunResourceConversionTestForPricingPlan, PricingPlanGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

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

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

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

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

// PricingPlanGenerator returns a generator of PricingPlan instances for property testing.
func PricingPlanGenerator() gopter.Gen {
	if pricingPlanGenerator != nil {
		return pricingPlanGenerator
	}

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

	return pricingPlanGenerator
}

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

func Test_PricingPlanOperatorSpec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from PricingPlanOperatorSpec to PricingPlanOperatorSpec via AssignProperties_To_PricingPlanOperatorSpec & AssignProperties_From_PricingPlanOperatorSpec returns original",
		prop.ForAll(RunPropertyAssignmentTestForPricingPlanOperatorSpec, PricingPlanOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

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

// PricingPlanOperatorSpecGenerator returns a generator of PricingPlanOperatorSpec instances for property testing.
func PricingPlanOperatorSpecGenerator() gopter.Gen {
	if pricingPlanOperatorSpecGenerator != nil {
		return pricingPlanOperatorSpecGenerator
	}

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

	return pricingPlanOperatorSpecGenerator
}

func Test_PricingPlan_STATUS_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from PricingPlan_STATUS to PricingPlan_STATUS via AssignProperties_To_PricingPlan_STATUS & AssignProperties_From_PricingPlan_STATUS returns original",
		prop.ForAll(RunPropertyAssignmentTestForPricingPlan_STATUS, PricingPlan_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual PricingPlan_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 PricingPlan_STATUS instances for property testing - lazily instantiated by PricingPlan_STATUSGenerator()
var pricingPlan_STATUSGenerator gopter.Gen

// PricingPlan_STATUSGenerator returns a generator of PricingPlan_STATUS instances for property testing.
func PricingPlan_STATUSGenerator() gopter.Gen {
	if pricingPlan_STATUSGenerator != nil {
		return pricingPlan_STATUSGenerator
	}

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

	return pricingPlan_STATUSGenerator
}

// AddIndependentPropertyGeneratorsForPricingPlan_STATUS is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPricingPlan_STATUS(gens map[string]gopter.Gen) {
	gens["Cap"] = gen.PtrOf(gen.Float64())
	gens["Id"] = gen.PtrOf(gen.AlphaString())
	gens["MaxHistoryCap"] = gen.PtrOf(gen.Float64())
	gens["Name"] = gen.PtrOf(gen.AlphaString())
	gens["PlanType"] = gen.PtrOf(gen.AlphaString())
	gens["ResetHour"] = gen.PtrOf(gen.Int())
	gens["StopSendNotificationWhenHitCap"] = gen.PtrOf(gen.Bool())
	gens["StopSendNotificationWhenHitThreshold"] = gen.PtrOf(gen.Bool())
	gens["Type"] = gen.PtrOf(gen.AlphaString())
	gens["WarningThreshold"] = gen.PtrOf(gen.Int())
}

func Test_PricingPlan_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
	t.Parallel()
	parameters := gopter.DefaultTestParameters()
	parameters.MaxSize = 10
	properties := gopter.NewProperties(parameters)
	properties.Property(
		"Round trip from PricingPlan_Spec to PricingPlan_Spec via AssignProperties_To_PricingPlan_Spec & AssignProperties_From_PricingPlan_Spec returns original",
		prop.ForAll(RunPropertyAssignmentTestForPricingPlan_Spec, PricingPlan_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
}

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

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

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

	// Deserialize back into memory
	var actual PricingPlan_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 PricingPlan_Spec instances for property testing - lazily instantiated by PricingPlan_SpecGenerator()
var pricingPlan_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForPricingPlan_Spec(generators)
	AddRelatedPropertyGeneratorsForPricingPlan_Spec(generators)
	pricingPlan_SpecGenerator = gen.Struct(reflect.TypeOf(PricingPlan_Spec{}), generators)

	return pricingPlan_SpecGenerator
}

// AddIndependentPropertyGeneratorsForPricingPlan_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForPricingPlan_Spec(gens map[string]gopter.Gen) {
	gens["Cap"] = gen.PtrOf(gen.Float64())
	gens["PlanType"] = gen.PtrOf(gen.AlphaString())
	gens["StopSendNotificationWhenHitCap"] = gen.PtrOf(gen.Bool())
	gens["StopSendNotificationWhenHitThreshold"] = gen.PtrOf(gen.Bool())
	gens["WarningThreshold"] = gen.PtrOf(gen.Int())
}

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