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

import (
	"encoding/json"
	"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_ActionGroupReference_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 ActionGroupReference via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForActionGroupReference, ActionGroupReferenceGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ActionGroupReferenceGenerator returns a generator of ActionGroupReference instances for property testing.
func ActionGroupReferenceGenerator() gopter.Gen {
	if actionGroupReferenceGenerator != nil {
		return actionGroupReferenceGenerator
	}

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

	return actionGroupReferenceGenerator
}

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

func Test_ActionList_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 ActionList via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForActionList, ActionListGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ActionListGenerator returns a generator of ActionList instances for property testing.
func ActionListGenerator() gopter.Gen {
	if actionListGenerator != nil {
		return actionListGenerator
	}

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

	return actionListGenerator
}

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

func Test_ActivityLogAlert_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 ActivityLogAlert_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForActivityLogAlert_Spec, ActivityLogAlert_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ActivityLogAlert_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 ActivityLogAlert_Spec instances for property testing - lazily instantiated by
// ActivityLogAlert_SpecGenerator()
var activityLogAlert_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForActivityLogAlert_Spec(generators)
	AddRelatedPropertyGeneratorsForActivityLogAlert_Spec(generators)
	activityLogAlert_SpecGenerator = gen.Struct(reflect.TypeOf(ActivityLogAlert_Spec{}), generators)

	return activityLogAlert_SpecGenerator
}

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

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

func Test_AlertRuleAllOfCondition_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 AlertRuleAllOfCondition via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAlertRuleAllOfCondition, AlertRuleAllOfConditionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// AlertRuleAllOfConditionGenerator returns a generator of AlertRuleAllOfCondition instances for property testing.
func AlertRuleAllOfConditionGenerator() gopter.Gen {
	if alertRuleAllOfConditionGenerator != nil {
		return alertRuleAllOfConditionGenerator
	}

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

	return alertRuleAllOfConditionGenerator
}

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

func Test_AlertRuleAnyOfOrLeafCondition_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 AlertRuleAnyOfOrLeafCondition via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAlertRuleAnyOfOrLeafCondition, AlertRuleAnyOfOrLeafConditionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAlertRuleAnyOfOrLeafCondition(generators)
	AddRelatedPropertyGeneratorsForAlertRuleAnyOfOrLeafCondition(generators)
	alertRuleAnyOfOrLeafConditionGenerator = gen.Struct(reflect.TypeOf(AlertRuleAnyOfOrLeafCondition{}), generators)

	return alertRuleAnyOfOrLeafConditionGenerator
}

// AddIndependentPropertyGeneratorsForAlertRuleAnyOfOrLeafCondition is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForAlertRuleAnyOfOrLeafCondition(gens map[string]gopter.Gen) {
	gens["ContainsAny"] = gen.SliceOf(gen.AlphaString())
	gens["Equals"] = gen.PtrOf(gen.AlphaString())
	gens["Field"] = gen.PtrOf(gen.AlphaString())
}

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

func Test_AlertRuleLeafCondition_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 AlertRuleLeafCondition via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAlertRuleLeafCondition, AlertRuleLeafConditionGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// AlertRuleLeafConditionGenerator returns a generator of AlertRuleLeafCondition instances for property testing.
func AlertRuleLeafConditionGenerator() gopter.Gen {
	if alertRuleLeafConditionGenerator != nil {
		return alertRuleLeafConditionGenerator
	}

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

	return alertRuleLeafConditionGenerator
}

// AddIndependentPropertyGeneratorsForAlertRuleLeafCondition is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForAlertRuleLeafCondition(gens map[string]gopter.Gen) {
	gens["ContainsAny"] = gen.SliceOf(gen.AlphaString())
	gens["Equals"] = gen.PtrOf(gen.AlphaString())
	gens["Field"] = gen.PtrOf(gen.AlphaString())
}

func Test_AlertRuleProperties_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 AlertRuleProperties via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAlertRuleProperties, AlertRulePropertiesGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAlertRuleProperties(generators)
	AddRelatedPropertyGeneratorsForAlertRuleProperties(generators)
	alertRulePropertiesGenerator = gen.Struct(reflect.TypeOf(AlertRuleProperties{}), generators)

	return alertRulePropertiesGenerator
}

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

// AddRelatedPropertyGeneratorsForAlertRuleProperties is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForAlertRuleProperties(gens map[string]gopter.Gen) {
	gens["Actions"] = gen.PtrOf(ActionListGenerator())
	gens["Condition"] = gen.PtrOf(AlertRuleAllOfConditionGenerator())
}
