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

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_AuthorizationProvidersAuthorizationsAccessPolicy_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 AuthorizationProvidersAuthorizationsAccessPolicy via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAuthorizationProvidersAuthorizationsAccessPolicy, AuthorizationProvidersAuthorizationsAccessPolicyGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// AuthorizationProvidersAuthorizationsAccessPolicyGenerator returns a generator of AuthorizationProvidersAuthorizationsAccessPolicy instances for property testing.
func AuthorizationProvidersAuthorizationsAccessPolicyGenerator() gopter.Gen {
	if authorizationProvidersAuthorizationsAccessPolicyGenerator != nil {
		return authorizationProvidersAuthorizationsAccessPolicyGenerator
	}

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

	return authorizationProvidersAuthorizationsAccessPolicyGenerator
}

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

func Test_AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpec_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 AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAuthorizationProvidersAuthorizationsAccessPolicyOperatorSpec, AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator returns a generator of AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpec instances for property testing.
func AuthorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator() gopter.Gen {
	if authorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator != nil {
		return authorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator
	}

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

	return authorizationProvidersAuthorizationsAccessPolicyOperatorSpecGenerator
}

func Test_AuthorizationProvidersAuthorizationsAccessPolicy_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 AuthorizationProvidersAuthorizationsAccessPolicy_STATUS via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAuthorizationProvidersAuthorizationsAccessPolicy_STATUS, AuthorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual AuthorizationProvidersAuthorizationsAccessPolicy_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 AuthorizationProvidersAuthorizationsAccessPolicy_STATUS instances for property testing - lazily
// instantiated by AuthorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator()
var authorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator gopter.Gen

// AuthorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator returns a generator of AuthorizationProvidersAuthorizationsAccessPolicy_STATUS instances for property testing.
func AuthorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator() gopter.Gen {
	if authorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator != nil {
		return authorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator
	}

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

	return authorizationProvidersAuthorizationsAccessPolicy_STATUSGenerator
}

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

func Test_AuthorizationProvidersAuthorizationsAccessPolicy_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 AuthorizationProvidersAuthorizationsAccessPolicy_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForAuthorizationProvidersAuthorizationsAccessPolicy_Spec, AuthorizationProvidersAuthorizationsAccessPolicy_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual AuthorizationProvidersAuthorizationsAccessPolicy_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 AuthorizationProvidersAuthorizationsAccessPolicy_Spec instances for property testing - lazily
// instantiated by AuthorizationProvidersAuthorizationsAccessPolicy_SpecGenerator()
var authorizationProvidersAuthorizationsAccessPolicy_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForAuthorizationProvidersAuthorizationsAccessPolicy_Spec(generators)
	AddRelatedPropertyGeneratorsForAuthorizationProvidersAuthorizationsAccessPolicy_Spec(generators)
	authorizationProvidersAuthorizationsAccessPolicy_SpecGenerator = gen.Struct(reflect.TypeOf(AuthorizationProvidersAuthorizationsAccessPolicy_Spec{}), generators)

	return authorizationProvidersAuthorizationsAccessPolicy_SpecGenerator
}

// AddIndependentPropertyGeneratorsForAuthorizationProvidersAuthorizationsAccessPolicy_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForAuthorizationProvidersAuthorizationsAccessPolicy_Spec(gens map[string]gopter.Gen) {
	gens["AppIds"] = gen.SliceOf(gen.AlphaString())
	gens["AzureName"] = gen.AlphaString()
	gens["ObjectId"] = gen.PtrOf(gen.AlphaString())
	gens["OriginalVersion"] = gen.AlphaString()
	gens["TenantId"] = gen.PtrOf(gen.AlphaString())
}

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