// 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_GitHubActionCodeConfiguration_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 GitHubActionCodeConfiguration via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForGitHubActionCodeConfiguration, GitHubActionCodeConfigurationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// GitHubActionCodeConfigurationGenerator returns a generator of GitHubActionCodeConfiguration instances for property testing.
func GitHubActionCodeConfigurationGenerator() gopter.Gen {
	if gitHubActionCodeConfigurationGenerator != nil {
		return gitHubActionCodeConfigurationGenerator
	}

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

	return gitHubActionCodeConfigurationGenerator
}

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

func Test_GitHubActionConfiguration_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 GitHubActionConfiguration via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForGitHubActionConfiguration, GitHubActionConfigurationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForGitHubActionConfiguration(generators)
	AddRelatedPropertyGeneratorsForGitHubActionConfiguration(generators)
	gitHubActionConfigurationGenerator = gen.Struct(reflect.TypeOf(GitHubActionConfiguration{}), generators)

	return gitHubActionConfigurationGenerator
}

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

// AddRelatedPropertyGeneratorsForGitHubActionConfiguration is a factory method for creating gopter generators
func AddRelatedPropertyGeneratorsForGitHubActionConfiguration(gens map[string]gopter.Gen) {
	gens["CodeConfiguration"] = gen.PtrOf(GitHubActionCodeConfigurationGenerator())
	gens["ContainerConfiguration"] = gen.PtrOf(GitHubActionContainerConfigurationGenerator())
}

func Test_GitHubActionContainerConfiguration_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 GitHubActionContainerConfiguration via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForGitHubActionContainerConfiguration, GitHubActionContainerConfigurationGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

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

// GitHubActionContainerConfigurationGenerator returns a generator of GitHubActionContainerConfiguration instances for property testing.
func GitHubActionContainerConfigurationGenerator() gopter.Gen {
	if gitHubActionContainerConfigurationGenerator != nil {
		return gitHubActionContainerConfigurationGenerator
	}

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

	return gitHubActionContainerConfigurationGenerator
}

// AddIndependentPropertyGeneratorsForGitHubActionContainerConfiguration is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForGitHubActionContainerConfiguration(gens map[string]gopter.Gen) {
	gens["ImageName"] = gen.PtrOf(gen.AlphaString())
	gens["Password"] = gen.PtrOf(gen.AlphaString())
	gens["ServerUrl"] = gen.PtrOf(gen.AlphaString())
	gens["Username"] = gen.PtrOf(gen.AlphaString())
}

func Test_SitesSourcecontrol_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 SitesSourcecontrol_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSitesSourcecontrol_Spec, SitesSourcecontrol_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual SitesSourcecontrol_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 SitesSourcecontrol_Spec instances for property testing - lazily instantiated by
// SitesSourcecontrol_SpecGenerator()
var sitesSourcecontrol_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSitesSourcecontrol_Spec(generators)
	AddRelatedPropertyGeneratorsForSitesSourcecontrol_Spec(generators)
	sitesSourcecontrol_SpecGenerator = gen.Struct(reflect.TypeOf(SitesSourcecontrol_Spec{}), generators)

	return sitesSourcecontrol_SpecGenerator
}

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

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

func Test_Sites_Sourcecontrol_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 Sites_Sourcecontrol_Properties_Spec via JSON returns original",
		prop.ForAll(RunJSONSerializationTestForSites_Sourcecontrol_Properties_Spec, Sites_Sourcecontrol_Properties_SpecGenerator()))
	properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
}

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

	// Deserialize back into memory
	var actual Sites_Sourcecontrol_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 Sites_Sourcecontrol_Properties_Spec instances for property testing - lazily instantiated by
// Sites_Sourcecontrol_Properties_SpecGenerator()
var sites_Sourcecontrol_Properties_SpecGenerator gopter.Gen

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

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

	// The above call to gen.Struct() captures the map, so create a new one
	generators = make(map[string]gopter.Gen)
	AddIndependentPropertyGeneratorsForSites_Sourcecontrol_Properties_Spec(generators)
	AddRelatedPropertyGeneratorsForSites_Sourcecontrol_Properties_Spec(generators)
	sites_Sourcecontrol_Properties_SpecGenerator = gen.Struct(reflect.TypeOf(Sites_Sourcecontrol_Properties_Spec{}), generators)

	return sites_Sourcecontrol_Properties_SpecGenerator
}

// AddIndependentPropertyGeneratorsForSites_Sourcecontrol_Properties_Spec is a factory method for creating gopter generators
func AddIndependentPropertyGeneratorsForSites_Sourcecontrol_Properties_Spec(gens map[string]gopter.Gen) {
	gens["Branch"] = gen.PtrOf(gen.AlphaString())
	gens["DeploymentRollbackEnabled"] = gen.PtrOf(gen.Bool())
	gens["IsGitHubAction"] = gen.PtrOf(gen.Bool())
	gens["IsManualIntegration"] = gen.PtrOf(gen.Bool())
	gens["IsMercurial"] = gen.PtrOf(gen.Bool())
	gens["RepoUrl"] = gen.PtrOf(gen.AlphaString())
}

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