public void It_should_upload_and_download_teams() { var userRole1 = new UserRole(new ElementIdentifier("userRole1"), CreateItem <string>(), CreateItem <IEnumerable <Permission> >()); var userRole2 = new UserRole(new ElementIdentifier("userRole2"), CreateItem <string>(), CreateItem <IEnumerable <Permission> >()); var lifecycle = new Lifecycle( new ElementIdentifier("lifecycle1"), "", new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), Enumerable.Empty <Phase>()); var projectGroup1 = new ProjectGroup(new ElementIdentifier("group1"), ""); var project1 = new Project(new ElementIdentifier("project1"), "", false, false, false, new DeploymentProcess(Enumerable.Empty <DeploymentStep>()), Enumerable.Empty <Variable>(), Enumerable.Empty <ElementReference>(), new ElementReference("lifecycle1"), new ElementReference("group1"), null, Enumerable.Empty <ProjectTrigger>(), TenantedDeploymentMode.TenantedOrUntenanted); var environment1 = new Environment(new ElementIdentifier("env1"), CreateItem <string>()); var team = new Team( CreateItemWithRename <ElementIdentifier>(false), new List <ElementReference> { new ElementReference("username1") }, new List <string> { "externalSecurityGroup1" }, new List <ElementReference> { new ElementReference(userRole1.Identifier.Name), new ElementReference(userRole2.Identifier.Name) }, new List <ElementReference> { new ElementReference(project1.Identifier.Name) }, new List <ElementReference> { new ElementReference(environment1.Identifier.Name) }); var expected = new SystemModelBuilder() .AddLifecycle(lifecycle) .AddProjectGroup(projectGroup1) .AddProject(project1) .AddEnvironment(environment1) .AddUserRole(userRole1) .AddUserRole(userRole2) .AddTeam(team) .Build(); _repository.Users.Register(new RegisterCommand { Username = "******" }); _uploader.UploadModel(expected).GetAwaiter(); var actual = _downloader.DownloadModel().GetAwaiter().GetResult(); actual.AssertDeepEqualsTo(expected); }
public void It_should_upload_and_download_library_variable_sets() { var environment1 = new Environment(new ElementIdentifier("env1"), CreateItem <string>()); var environment2 = new Environment(new ElementIdentifier("env2"), CreateItem <string>()); var scope = new Dictionary <VariableScopeType, IEnumerable <ElementReference> > { { VariableScopeType.Environment, new[] { new ElementReference("env1"), new ElementReference("env2") } }, { VariableScopeType.Machine, new[] { new ElementReference("m1"), new ElementReference("m2") } }, { VariableScopeType.Role, new[] { new ElementReference("r1"), new ElementReference("r2") } }, { VariableScopeType.Channel, new[] { new ElementReference("ch1"), new ElementReference("ch2") } } }; var expected = new SystemModelBuilder() .AddEnvironment(environment1) .AddEnvironment(environment2) .AddLibraryVariableSet(CreateItemWithRename <LibraryVariableSet>(false)) .AddLibraryVariableSet(new LibraryVariableSet(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), CreateItem <LibraryVariableSet.VariableSetContentType>(), new[] { new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()), new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()), new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()) })) .Build(); _repository.Machines.Create(new MachineResource { Name = "m1" }); _repository.Machines.Create(new MachineResource { Name = "m2" }); //_repository.FakeMachineRoles.Add("r1"); //_repository.FakeMachineRoles.Add("r2"); _repository.Channels.Create(new ChannelResource { Name = "ch1" }); _repository.Channels.Create(new ChannelResource { Name = "ch2" }); _uploader.UploadModel(expected).GetAwaiter(); var actual = _downloader.DownloadModel().GetAwaiter().GetResult(); actual.AssertDeepEqualsTo(expected); }
public void It_should_upload_and_download_lifecycles() { var environment1 = new Environment(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>()); var environment2 = new Environment(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>()); var environment3 = new Environment(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>()); var lifecycle = new Lifecycle( CreateItemWithRename <ElementIdentifier>(false), string.Empty, new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), new[] { new Phase(CreateItemWithRename <ElementIdentifier>(false), CreateItem <RetentionPolicy>(), CreateItem <RetentionPolicy>(), CreateItem <int>(), new[] { new ElementReference(environment1.Identifier.Name), new ElementReference(environment2.Identifier.Name) }, new[] { new ElementReference(environment3.Identifier.Name) }), new Phase(CreateItemWithRename <ElementIdentifier>(false), CreateItem <RetentionPolicy>(), CreateItem <RetentionPolicy>(), CreateItem <int>(), new[] { new ElementReference(environment2.Identifier.Name), new ElementReference(environment3.Identifier.Name) }, new[] { new ElementReference(environment1.Identifier.Name) }) }); var expected = new SystemModelBuilder() .AddEnvironment(environment1) .AddEnvironment(environment2) .AddEnvironment(environment3) .AddLifecycle(lifecycle) .Build(); _uploader.UploadModel(expected).GetAwaiter(); var actual = _downloader.DownloadModel().GetAwaiter().GetResult(); actual.AssertDeepEqualsTo(expected); }
public void It_should_upload_and_download_tenant() { var tagset = new TagSet(new ElementIdentifier("ts1"), new List <string> { "t1", "t2" }); var environment1 = new Environment(new ElementIdentifier("env1"), CreateItem <string>()); var projectGroup = new ProjectGroup(CreateItemWithRename <ElementIdentifier>(false), string.Empty); var libraryVariableSet = new LibraryVariableSet(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), LibraryVariableSet.VariableSetContentType.Variables, Enumerable.Empty <Variable>()); var lifecycle = new Lifecycle( CreateItemWithRename <ElementIdentifier>(false), string.Empty, new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), Enumerable.Empty <Phase>()); var deploymentProcess = new DeploymentProcess(new List <DeploymentStep> { new DeploymentStep(CreateItem <string>(), CreateItem <DeploymentStep.StepCondition>(), CreateItem <bool>(), CreateItem <DeploymentStep.StepStartTrigger>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new DeploymentAction(CreateItem <string>(), CreateItem <string>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new ElementReference("env1") }), }) }); var scope = new Dictionary <VariableScopeType, IEnumerable <ElementReference> > { { VariableScopeType.Environment, new[] { new ElementReference("env1") } }, { VariableScopeType.Action, deploymentProcess.DeploymentSteps.SelectMany(s => s.Actions.Select(a => a.Name)) .Select(action => new ElementReference(action)) .ToArray() } }; var variables = new[] { new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()) }; var project1 = new Project(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <bool>(), deploymentProcess, variables, new[] { new ElementReference(libraryVariableSet.Identifier.Name) }, new ElementReference(lifecycle.Identifier.Name), new ElementReference(projectGroup.Identifier.Name), CreateItem <VersioningStrategy>(), Enumerable.Empty <ProjectTrigger>(), TenantedDeploymentMode.TenantedOrUntenanted); var tenant = new Tenant(new ElementIdentifier("t1"), new[] { new ElementReference(tagset.Identifier.Name) }, new Dictionary <string, IEnumerable <string> > { { project1.Identifier.Name, new[] { environment1.Identifier.Name } } }); var expected = new SystemModelBuilder() .AddProject(project1) .AddTenant(tenant) .AddProjectGroup(projectGroup) .AddLifecycle(lifecycle) .AddLibraryVariableSet(libraryVariableSet) .AddEnvironment(environment1) .Build(); _uploader.UploadModel(expected).GetAwaiter(); var actual = _downloader.DownloadModel().GetAwaiter().GetResult(); actual.AssertDeepEqualsTo(expected); }
public void It_should_upload_and_download_projects() { var environment1 = new Environment(new ElementIdentifier("env1"), CreateItem <string>()); var environment2 = new Environment(new ElementIdentifier("env2"), CreateItem <string>()); var projectGroup = new ProjectGroup(CreateItemWithRename <ElementIdentifier>(false), string.Empty); var libraryVariableSet = new LibraryVariableSet(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), LibraryVariableSet.VariableSetContentType.Variables, Enumerable.Empty <Variable>()); var lifecycle = new Lifecycle( CreateItemWithRename <ElementIdentifier>(false), string.Empty, new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), new RetentionPolicy(0, RetentionPolicy.RetentionUnit.Items), Enumerable.Empty <Phase>()); var deploymentProcess = new DeploymentProcess(new List <DeploymentStep> { new DeploymentStep(CreateItem <string>(), CreateItem <DeploymentStep.StepCondition>(), CreateItem <bool>(), CreateItem <DeploymentStep.StepStartTrigger>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new DeploymentAction(CreateItem <string>(), CreateItem <string>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new ElementReference("env1") }), new DeploymentAction(CreateItem <string>(), CreateItem <string>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new ElementReference("env2") }) }), new DeploymentStep(CreateItem <string>(), CreateItem <DeploymentStep.StepCondition>(), CreateItem <bool>(), CreateItem <DeploymentStep.StepStartTrigger>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new DeploymentAction(CreateItem <string>(), CreateItem <string>(), CreateItem <IReadOnlyDictionary <string, PropertyValue> >(), new[] { new ElementReference("env1") }) }) }); var scope = new Dictionary <VariableScopeType, IEnumerable <ElementReference> > { { VariableScopeType.Environment, new[] { new ElementReference("env1"), new ElementReference("env2") } }, { VariableScopeType.Machine, new[] { new ElementReference("m1"), new ElementReference("m2") } }, { VariableScopeType.Role, new[] { new ElementReference("r1"), new ElementReference("r2") } }, { VariableScopeType.Channel, new[] { new ElementReference("ch1"), new ElementReference("ch2") } }, { VariableScopeType.Action, deploymentProcess.DeploymentSteps.SelectMany(s => s.Actions.Select(a => a.Name)) .Select(action => new ElementReference(action)) .ToArray() } }; var variables = new[] { new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()), new Variable(CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <string>(), scope, CreateItem <VariablePrompt>()) }; var project1 = new Project(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <bool>(), deploymentProcess, variables, new[] { new ElementReference(libraryVariableSet.Identifier.Name) }, new ElementReference(lifecycle.Identifier.Name), new ElementReference(projectGroup.Identifier.Name), CreateItem <VersioningStrategy>(), Enumerable.Empty <ProjectTrigger>(), TenantedDeploymentMode.TenantedOrUntenanted); var project2 = new Project(CreateItemWithRename <ElementIdentifier>(false), CreateItem <string>(), CreateItem <bool>(), CreateItem <bool>(), CreateItem <bool>(), deploymentProcess, variables, new[] { new ElementReference(libraryVariableSet.Identifier.Name) }, new ElementReference(lifecycle.Identifier.Name), new ElementReference(projectGroup.Identifier.Name), null, new[] { CreateProjectTrigger("m1", "env1"), CreateProjectTrigger("m2", "env2") }, TenantedDeploymentMode.TenantedOrUntenanted); var expected = new SystemModelBuilder() .AddProject(project1) .AddProject(project2) .AddProjectGroup(projectGroup) .AddLifecycle(lifecycle) .AddLibraryVariableSet(libraryVariableSet) .AddEnvironment(environment1) .AddEnvironment(environment2) .Build(); _repository.Machines.Create(new MachineResource { Name = "m1" }); _repository.Machines.Create(new MachineResource { Name = "m2" }); //_repository.FakeMachineRoles.Add("r1"); //_repository.FakeMachineRoles.Add("r2"); _repository.Channels.Create(new ChannelResource { Name = "ch1" }); _repository.Channels.Create(new ChannelResource { Name = "ch2" }); _uploader.UploadModel(expected).GetAwaiter(); var actual = _downloader.DownloadModel().GetAwaiter().GetResult(); actual.AssertDeepEqualsTo(expected); }