// 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_ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbedded_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 ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbedded via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbedded, ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator returns a generator of ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbedded instances for property testing.
func ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator() gopter.Gen {
	if applicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator != nil {
		return applicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator
	}

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

	return applicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator
}

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

func Test_NetworkSecurityGroupPropertiesFormat_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 NetworkSecurityGroupPropertiesFormat via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNetworkSecurityGroupPropertiesFormat, NetworkSecurityGroupPropertiesFormatGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNetworkSecurityGroupPropertiesFormat(generators)
	AddRelatedPropertyGeneratorsForNetworkSecurityGroupPropertiesFormat(generators)
	networkSecurityGroupPropertiesFormatGenerator = gen.Struct(reflect.TypeOf(NetworkSecurityGroupPropertiesFormat{}), generators)

	return networkSecurityGroupPropertiesFormatGenerator
}

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

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

func Test_NetworkSecurityGroup_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 NetworkSecurityGroup_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForNetworkSecurityGroup_Spec, NetworkSecurityGroup_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual NetworkSecurityGroup_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 NetworkSecurityGroup_Spec instances for property testing - lazily instantiated by
// NetworkSecurityGroup_SpecGenerator()
var networkSecurityGroup_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForNetworkSecurityGroup_Spec(generators)
	AddRelatedPropertyGeneratorsForNetworkSecurityGroup_Spec(generators)
	networkSecurityGroup_SpecGenerator = gen.Struct(reflect.TypeOf(NetworkSecurityGroup_Spec{}), generators)

	return networkSecurityGroup_SpecGenerator
}

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

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

func Test_SecurityRule_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 SecurityRule via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSecurityRule, SecurityRuleGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSecurityRule(generators)
	AddRelatedPropertyGeneratorsForSecurityRule(generators)
	securityRuleGenerator = gen.Struct(reflect.TypeOf(SecurityRule{}), generators)

	return securityRuleGenerator
}

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

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

func Test_SecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded_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 SecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded, SecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbeddedGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded(generators)
	AddRelatedPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded(generators)
	securityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbeddedGenerator = gen.Struct(reflect.TypeOf(SecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded{}), generators)

	return securityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbeddedGenerator
}

// AddIndependentPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded(gens map[string]gopter.Gen) {
	gens["Access"] = gen.PtrOf(gen.OneConstOf(SecurityRuleAccess_Allow, SecurityRuleAccess_Deny))
	gens["Description"] = gen.PtrOf(gen.AlphaString())
	gens["DestinationAddressPrefix"] = gen.PtrOf(gen.AlphaString())
	gens["DestinationAddressPrefixes"] = gen.SliceOf(gen.AlphaString())
	gens["DestinationPortRange"] = gen.PtrOf(gen.AlphaString())
	gens["DestinationPortRanges"] = gen.SliceOf(gen.AlphaString())
	gens["Direction"] = gen.PtrOf(gen.OneConstOf(SecurityRuleDirection_Inbound, SecurityRuleDirection_Outbound))
	gens["Priority"] = gen.PtrOf(gen.Int())
	gens["Protocol"] = gen.PtrOf(gen.OneConstOf(
		SecurityRulePropertiesFormat_Protocol_Ah,
		SecurityRulePropertiesFormat_Protocol_Esp,
		SecurityRulePropertiesFormat_Protocol_Icmp,
		SecurityRulePropertiesFormat_Protocol_Star,
		SecurityRulePropertiesFormat_Protocol_Tcp,
		SecurityRulePropertiesFormat_Protocol_Udp))
	gens["SourceAddressPrefix"] = gen.PtrOf(gen.AlphaString())
	gens["SourceAddressPrefixes"] = gen.SliceOf(gen.AlphaString())
	gens["SourcePortRange"] = gen.PtrOf(gen.AlphaString())
	gens["SourcePortRanges"] = gen.SliceOf(gen.AlphaString())
}

// AddRelatedPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForSecurityRulePropertiesFormat_NetworkSecurityGroup_SubResourceEmbedded(gens map[string]gopter.Gen) {
	gens["DestinationApplicationSecurityGroups"] = gen.SliceOf(ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator())
	gens["SourceApplicationSecurityGroups"] = gen.SliceOf(ApplicationSecurityGroupSpec_NetworkSecurityGroup_SubResourceEmbeddedGenerator())
}
