// 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_OutboundFirewallRuleProperties_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 OutboundFirewallRuleProperties_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForOutboundFirewallRuleProperties_STATUS, OutboundFirewallRuleProperties_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual OutboundFirewallRuleProperties_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 OutboundFirewallRuleProperties_STATUS instances for property testing - lazily instantiated by
// OutboundFirewallRuleProperties_STATUSGenerator()
var outboundFirewallRuleProperties_STATUSGenerator gopter.Gen

// OutboundFirewallRuleProperties_STATUSGenerator returns a generator of OutboundFirewallRuleProperties_STATUS instances for property testing.
func OutboundFirewallRuleProperties_STATUSGenerator() gopter.Gen {
	if outboundFirewallRuleProperties_STATUSGenerator != nil {
		return outboundFirewallRuleProperties_STATUSGenerator
	}

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

	return outboundFirewallRuleProperties_STATUSGenerator
}

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

func Test_ServersOutboundFirewallRule_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 ServersOutboundFirewallRule_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForServersOutboundFirewallRule_STATUS, ServersOutboundFirewallRule_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual ServersOutboundFirewallRule_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 ServersOutboundFirewallRule_STATUS instances for property testing - lazily instantiated by
// ServersOutboundFirewallRule_STATUSGenerator()
var serversOutboundFirewallRule_STATUSGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForServersOutboundFirewallRule_STATUS(generators)
	AddRelatedPropertyGeneratorsForServersOutboundFirewallRule_STATUS(generators)
	serversOutboundFirewallRule_STATUSGenerator = gen.Struct(reflect.TypeOf(ServersOutboundFirewallRule_STATUS{}), generators)

	return serversOutboundFirewallRule_STATUSGenerator
}

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

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