// 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_Multichannel_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 Multichannel via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForMultichannel, MultichannelGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// MultichannelGenerator returns a generator of Multichannel instances for property testing.
func MultichannelGenerator() gopter.Gen {
	if multichannelGenerator != nil {
		return multichannelGenerator
	}

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

	return multichannelGenerator
}

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

func Test_ProtocolSettings_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 ProtocolSettings via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForProtocolSettings, ProtocolSettingsGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// ProtocolSettingsGenerator returns a generator of ProtocolSettings instances for property testing.
func ProtocolSettingsGenerator() gopter.Gen {
	if protocolSettingsGenerator != nil {
		return protocolSettingsGenerator
	}

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

	return protocolSettingsGenerator
}

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

func Test_SmbSetting_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 SmbSetting via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSmbSetting, SmbSettingGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSmbSetting(generators)
	AddRelatedPropertyGeneratorsForSmbSetting(generators)
	smbSettingGenerator = gen.Struct(reflect.TypeOf(SmbSetting{}), generators)

	return smbSettingGenerator
}

// AddIndependentPropertyGeneratorsForSmbSetting is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSmbSetting(gens map[string]gopter.Gen) {
	gens["AuthenticationMethods"] = gen.PtrOf(gen.AlphaString())
	gens["ChannelEncryption"] = gen.PtrOf(gen.AlphaString())
	gens["KerberosTicketEncryption"] = gen.PtrOf(gen.AlphaString())
	gens["Versions"] = gen.PtrOf(gen.AlphaString())
}

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

func Test_StorageAccountsFileService_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 StorageAccountsFileService_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccountsFileService_Spec, StorageAccountsFileService_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccountsFileService_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 StorageAccountsFileService_Spec instances for property testing - lazily instantiated by
// StorageAccountsFileService_SpecGenerator()
var storageAccountsFileService_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForStorageAccountsFileService_Spec(generators)
	AddRelatedPropertyGeneratorsForStorageAccountsFileService_Spec(generators)
	storageAccountsFileService_SpecGenerator = gen.Struct(reflect.TypeOf(StorageAccountsFileService_Spec{}), generators)

	return storageAccountsFileService_SpecGenerator
}

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

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

func Test_StorageAccounts_FileService_Properties_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 StorageAccounts_FileService_Properties_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForStorageAccounts_FileService_Properties_Spec, StorageAccounts_FileService_Properties_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual StorageAccounts_FileService_Properties_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 StorageAccounts_FileService_Properties_Spec instances for property testing - lazily instantiated by
// StorageAccounts_FileService_Properties_SpecGenerator()
var storageAccounts_FileService_Properties_SpecGenerator gopter.Gen

// StorageAccounts_FileService_Properties_SpecGenerator returns a generator of StorageAccounts_FileService_Properties_Spec instances for property testing.
func StorageAccounts_FileService_Properties_SpecGenerator() gopter.Gen {
	if storageAccounts_FileService_Properties_SpecGenerator != nil {
		return storageAccounts_FileService_Properties_SpecGenerator
	}

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

	return storageAccounts_FileService_Properties_SpecGenerator
}

// AddRelatedPropertyGeneratorsForStorageAccounts_FileService_Properties_Spec is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForStorageAccounts_FileService_Properties_Spec(gens map[string]gopter.Gen) {
	gens["Cors"] = gen.PtrOf(CorsRulesGenerator())
	gens["ProtocolSettings"] = gen.PtrOf(ProtocolSettingsGenerator())
	gens["ShareDeleteRetentionPolicy"] = gen.PtrOf(DeleteRetentionPolicyGenerator())
}
