From d763340ecf76ae19e194eb83aa747d311d7e31b7 Mon Sep 17 00:00:00 2001 From: Colin Svingen Date: Tue, 25 Sep 2018 16:28:12 -0400 Subject: [PATCH] Cleans up unit tests --- Octopus-Cmdlets.Tests/AddEnvironmentTests.cs | 10 ++-- .../AddLibraryVariableTests.cs | 2 +- Octopus-Cmdlets.Tests/AddMachineTests.cs | 8 +-- Octopus-Cmdlets.Tests/AddNugetFeedTests.cs | 54 ++++++++++--------- Octopus-Cmdlets.Tests/AddProjectGroupTests.cs | 10 ++-- Octopus-Cmdlets.Tests/AddProjectTests.cs | 16 +++--- Octopus-Cmdlets.Tests/AddVariableSetTests.cs | 10 ++-- Octopus-Cmdlets.Tests/AddVariableTests.cs | 2 +- Octopus-Cmdlets.Tests/CopyChannelTests.cs | 22 ++++---- Octopus-Cmdlets.Tests/CopyProjectTests.cs | 12 ++--- Octopus-Cmdlets.Tests/GetActionTests.cs | 10 ++-- .../GetDeploymentProcessTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetDeploymentTests.cs | 8 +-- Octopus-Cmdlets.Tests/GetEnvironmentTests.cs | 12 ++--- Octopus-Cmdlets.Tests/GetExternalFeedTests.cs | 4 +- Octopus-Cmdlets.Tests/GetMachineRoleTests.cs | 4 +- Octopus-Cmdlets.Tests/GetMachineTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetProjectGroupTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetProjectTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetReleaseTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetStepTests.cs | 28 +++------- Octopus-Cmdlets.Tests/GetVariableSetTests.cs | 10 ++-- Octopus-Cmdlets.Tests/GetVariableTests.cs | 10 ++-- .../Octopus-Cmdlets.Tests.csproj | 7 +-- .../RemoveEnvironmentTests.cs | 14 ++--- .../RemoveProjectGroupTests.cs | 14 ++--- Octopus-Cmdlets.Tests/RemoveProjectTests.cs | 14 ++--- .../RemoveVariableSetTests.cs | 17 +++--- Octopus-Cmdlets.Tests/RemoveVariableTests.cs | 4 +- .../UpdateLibraryVariableTests.cs | 4 +- Octopus-Cmdlets.Tests/UpdateVariableTests.cs | 4 +- Octopus-Cmdlets.Tests/UseVariableSetTests.cs | 4 +- Octopus-Cmdlets/AddEnvironment.cs | 2 +- Octopus-Cmdlets/AddNugetFeed.cs | 12 ++++- README.md | 11 +--- Version.cs | 4 +- 36 files changed, 193 insertions(+), 200 deletions(-) diff --git a/Octopus-Cmdlets.Tests/AddEnvironmentTests.cs b/Octopus-Cmdlets.Tests/AddEnvironmentTests.cs index f3ac41c..e8d8bde 100644 --- a/Octopus-Cmdlets.Tests/AddEnvironmentTests.cs +++ b/Octopus-Cmdlets.Tests/AddEnvironmentTests.cs @@ -21,8 +21,8 @@ public AddEnvironmentTests() _envs.Clear(); var envRepo = new Mock(); - envRepo.Setup(e => e.Create(It.IsAny(), null)) - .Returns(delegate(EnvironmentResource e) + envRepo.Setup(e => e.Create(It.IsAny(), It.IsAny())) + .Returns((EnvironmentResource e, object o) => { _envs.Add(e); return e; @@ -38,7 +38,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus_Dev"); _ps.Invoke(); - Assert.Equal(1, _envs.Count); + Assert.Single(_envs); Assert.Equal("Octopus_Dev", _envs[0].Name); } @@ -59,7 +59,7 @@ public void With_Name_And_Description() AddParameter("Description", "Octopus Development environment"); _ps.Invoke(); - Assert.Equal(1, _envs.Count); + Assert.Single(_envs); Assert.Equal("Octopus_Dev", _envs[0].Name); Assert.Equal("Octopus Development environment", _envs[0].Description); } @@ -73,7 +73,7 @@ public void With_Arguments() .AddArgument("Octopus Development environment"); _ps.Invoke(); - Assert.Equal(1, _envs.Count); + Assert.Single(_envs); Assert.Equal("Octopus_Dev", _envs[0].Name); Assert.Equal("Octopus Development environment", _envs[0].Description); } diff --git a/Octopus-Cmdlets.Tests/AddLibraryVariableTests.cs b/Octopus-Cmdlets.Tests/AddLibraryVariableTests.cs index 11021e5..8a6e0af 100644 --- a/Octopus-Cmdlets.Tests/AddLibraryVariableTests.cs +++ b/Octopus-Cmdlets.Tests/AddLibraryVariableTests.cs @@ -74,7 +74,7 @@ public void With_Invalid_VariableSet() { // Execute cmdlet _ps.AddCommand(CmdletName).AddParameter("VariableSet", "Gibberish").AddParameter("Name", "Test"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] diff --git a/Octopus-Cmdlets.Tests/AddMachineTests.cs b/Octopus-Cmdlets.Tests/AddMachineTests.cs index 8c382b8..07d9a0f 100644 --- a/Octopus-Cmdlets.Tests/AddMachineTests.cs +++ b/Octopus-Cmdlets.Tests/AddMachineTests.cs @@ -28,8 +28,8 @@ public AddMachineTests() _machines.Clear(); var machineRepo = new Mock(); - machineRepo.Setup(m => m.Create(It.IsAny(), null)) - .Returns(delegate(MachineResource m) + machineRepo.Setup(m => m.Create(It.IsAny(), It.IsAny())) + .Returns((MachineResource m, object o) => { _machines.Add(m); return m; @@ -49,7 +49,7 @@ public void With_EnvName() .AddParameter("Endpoint", new ListeningTentacleEndpointResource { Uri = "https://server.domain:port/", Thumbprint = "ThisIsMyThumbprint" }); _ps.Invoke(); - Assert.Equal(1, _machines.Count); + Assert.Single(_machines); Assert.Equal(new ReferenceCollection("environments-1").ToString(), _machines[0].EnvironmentIds.ToString()); Assert.Equal("Tentacle_Name", _machines[0].Name); Assert.Equal("ThisIsMyThumbprint", ((ListeningTentacleEndpointResource)_machines[0].Endpoint).Thumbprint); @@ -69,7 +69,7 @@ public void With_EnvId() .AddParameter("Endpoint", new ListeningTentacleEndpointResource { Uri = "https://server.domain:port/", Thumbprint = "ThisIsMyThumbprint" }); _ps.Invoke(); - Assert.Equal(1, _machines.Count); + Assert.Single(_machines); Assert.Equal(new ReferenceCollection("environments-1").ToString(), _machines[0].EnvironmentIds.ToString()); Assert.Equal("Tentacle_Name", _machines[0].Name); Assert.Equal("ThisIsMyThumbprint", ((ListeningTentacleEndpointResource)_machines[0].Endpoint).Thumbprint); diff --git a/Octopus-Cmdlets.Tests/AddNugetFeedTests.cs b/Octopus-Cmdlets.Tests/AddNugetFeedTests.cs index e8bba32..0e63ab4 100644 --- a/Octopus-Cmdlets.Tests/AddNugetFeedTests.cs +++ b/Octopus-Cmdlets.Tests/AddNugetFeedTests.cs @@ -11,7 +11,7 @@ public class AddNugetFeedTests { private const string CmdletName = "Add-OctoNugetFeed"; private PowerShell _ps; - private readonly List _feeds = new List(); + private readonly List _feeds = new List(); public AddNugetFeedTests() { @@ -21,8 +21,8 @@ public AddNugetFeedTests() _feeds.Clear(); var feedRepo = new Mock(); - feedRepo.Setup(e => e.Create(It.IsAny(), null)) - .Returns(delegate(FeedResource e) + feedRepo.Setup(e => e.Create(It.IsAny(), It.IsAny())) + .Returns((NuGetFeedResource e, object o) => { _feeds.Add(e); return e; @@ -38,7 +38,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus_Dev"); _ps.Invoke(); - Assert.Equal(1, _feeds.Count); + Assert.Single(_feeds); Assert.Equal("Octopus_Dev", _feeds[0].Name); } @@ -50,31 +50,33 @@ public void With_Uri() Assert.Throws(() => _ps.Invoke()); } - //[Fact] - //public void With_Name_And_Description() - //{ - // // Execute cmdlet - // _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus_Dev").AddParameter("Uri", "\\test"); - // _ps.Invoke(); + [Fact] + public void With_Name_And_Description() + { + // Execute cmdlet + _ps.AddCommand(CmdletName) + .AddParameter(nameof(AddNugetFeed.Name), "Octopus_Dev") + .AddParameter(nameof(AddNugetFeed.FeedUri), "\\test"); + _ps.Invoke(); - // Assert.Equal(1, _feeds.Count); - // Assert.Equal("Octopus_Dev", _feeds[0].Name); - // Assert.Equal("\\test", _feeds[0].FeedUri); - //} + Assert.Single(_feeds); + Assert.Equal("Octopus_Dev", _feeds[0].Name); + Assert.Equal("\\test", _feeds[0].FeedUri); + } - //[Fact] - //public void With_Arguements() - //{ - // // Execute cmdlet - // _ps.AddCommand(CmdletName) - // .AddArgument("Octopus_Dev") - // .AddArgument("\\test"); - // _ps.Invoke(); + [Fact] + public void With_Arguements() + { + // Execute cmdlet + _ps.AddCommand(CmdletName) + .AddArgument("Octopus_Dev") + .AddArgument("\\test"); + _ps.Invoke(); - // Assert.Equal(1, _feeds.Count); - // Assert.Equal("Octopus_Dev", _feeds[0].Name); - // Assert.Equal("\\test", _feeds[0].FeedUri); - //} + Assert.Single(_feeds); + Assert.Equal("Octopus_Dev", _feeds[0].Name); + Assert.Equal("\\test", _feeds[0].FeedUri); + } [Fact] public void No_Arguments() diff --git a/Octopus-Cmdlets.Tests/AddProjectGroupTests.cs b/Octopus-Cmdlets.Tests/AddProjectGroupTests.cs index dfc7d9b..a1c718f 100644 --- a/Octopus-Cmdlets.Tests/AddProjectGroupTests.cs +++ b/Octopus-Cmdlets.Tests/AddProjectGroupTests.cs @@ -21,8 +21,8 @@ public AddProjectGroupTests() _groups.Clear(); var repo = new Mock(); - repo.Setup(e => e.Create(It.IsAny(), null)) - .Returns(delegate(ProjectGroupResource p) + repo.Setup(e => e.Create(It.IsAny(), It.IsAny())) + .Returns((ProjectGroupResource p, object o) => { _groups.Add(p); return p; @@ -38,7 +38,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); _ps.Invoke(); - Assert.Equal(1, _groups.Count); + Assert.Single(_groups); Assert.Equal("Octopus", _groups[0].Name); } @@ -49,7 +49,7 @@ public void With_Name_Parameter() _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus"); _ps.Invoke(); - Assert.Equal(1, _groups.Count); + Assert.Single(_groups); Assert.Equal("Octopus", _groups[0].Name); } @@ -70,7 +70,7 @@ public void With_Name_And_Description() .AddArgument("Octopus Development Group"); _ps.Invoke(); - Assert.Equal(1, _groups.Count); + Assert.Single(_groups); Assert.Equal("Octopus", _groups[0].Name); Assert.Equal("Octopus Development Group", _groups[0].Description); } diff --git a/Octopus-Cmdlets.Tests/AddProjectTests.cs b/Octopus-Cmdlets.Tests/AddProjectTests.cs index 95e9f41..c873e3d 100644 --- a/Octopus-Cmdlets.Tests/AddProjectTests.cs +++ b/Octopus-Cmdlets.Tests/AddProjectTests.cs @@ -32,8 +32,8 @@ public AddProjectTests() _projects.Clear(); var repo = new Mock(); - repo.Setup(e => e.Create(It.IsAny(), null)) - .Returns(delegate(ProjectResource p) + repo.Setup(e => e.Create(It.IsAny(), It.IsAny())) + .Returns((ProjectResource p, object o) => { _projects.Add(p); return p; @@ -55,7 +55,7 @@ public void With_Invalid_ProjectGroup() { // Execute cmdlet _ps.AddCommand(CmdletName).AddParameter("ProjectGroup", "Gibberish").AddParameter("Name", "Octopus"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -71,7 +71,7 @@ public void With_Invalid_ProjectGroupId() { // Execute cmdlet _ps.AddCommand(CmdletName).AddParameter("ProjectGroupId", "Gibberish").AddParameter("Name", "Octopus"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -81,7 +81,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddParameter("ProjectGroup", "Octopus").AddParameter("Name", "Octopus"); _ps.Invoke(); - Assert.Equal(1, _projects.Count); + Assert.Single(_projects); Assert.Equal("Octopus", _projects[0].Name); } @@ -92,7 +92,7 @@ public void ById_With_Name() _ps.AddCommand(CmdletName).AddParameter("ProjectGroupId", "projectgroups-1").AddParameter("Name", "Octopus"); _ps.Invoke(); - Assert.Equal(1, _projects.Count); + Assert.Single(_projects); Assert.Equal("Octopus", _projects[0].Name); } @@ -124,7 +124,7 @@ public void With_Name_And_Description() .AddParameter("Description", "Octopus Development Project"); _ps.Invoke(); - Assert.Equal(1, _projects.Count); + Assert.Single(_projects); Assert.Equal("Octopus", _projects[0].Name); Assert.Equal("projectgroups-1", _projects[0].ProjectGroupId); Assert.Equal("Octopus Development Project", _projects[0].Description); @@ -140,7 +140,7 @@ public void With_Arguments() .AddArgument("Octopus Development Project"); _ps.Invoke(); - Assert.Equal(1, _projects.Count); + Assert.Single(_projects); Assert.Equal("Octopus", _projects[0].Name); Assert.Equal("projectgroups-1", _projects[0].ProjectGroupId); Assert.Equal("Octopus Development Project", _projects[0].Description); diff --git a/Octopus-Cmdlets.Tests/AddVariableSetTests.cs b/Octopus-Cmdlets.Tests/AddVariableSetTests.cs index 2d90344..eb8dc78 100644 --- a/Octopus-Cmdlets.Tests/AddVariableSetTests.cs +++ b/Octopus-Cmdlets.Tests/AddVariableSetTests.cs @@ -21,8 +21,8 @@ public AddVariableSetTests() _sets.Clear(); var repo = new Mock(); - repo.Setup(e => e.Create(It.IsAny(), null)) - .Returns(delegate(LibraryVariableSetResource e) + repo.Setup(e => e.Create(It.IsAny(), It.IsAny())) + .Returns((LibraryVariableSetResource e, object o) => { _sets.Add(e); return e; @@ -38,7 +38,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus"); _ps.Invoke(); - Assert.Equal(1, _sets.Count); + Assert.Single(_sets); Assert.Equal("Octopus", _sets[0].Name); } @@ -59,7 +59,7 @@ public void With_Name_And_Description() .AddParameter("Description", "VariableSet"); _ps.Invoke(); - Assert.Equal(1, _sets.Count); + Assert.Single(_sets); Assert.Equal("Octopus", _sets[0].Name); Assert.Equal("VariableSet", _sets[0].Description); } @@ -73,7 +73,7 @@ public void With_Arguments() .AddArgument("VariableSet"); _ps.Invoke(); - Assert.Equal(1, _sets.Count); + Assert.Single(_sets); Assert.Equal("Octopus", _sets[0].Name); Assert.Equal("VariableSet", _sets[0].Description); } diff --git a/Octopus-Cmdlets.Tests/AddVariableTests.cs b/Octopus-Cmdlets.Tests/AddVariableTests.cs index a52c6a2..5f27b4b 100644 --- a/Octopus-Cmdlets.Tests/AddVariableTests.cs +++ b/Octopus-Cmdlets.Tests/AddVariableTests.cs @@ -66,7 +66,7 @@ public void With_Invalid_Project() { // Execute cmdlet _ps.AddCommand(CmdletName).AddParameter("Project", "Gibberish").AddParameter("Name", "Test"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] diff --git a/Octopus-Cmdlets.Tests/CopyChannelTests.cs b/Octopus-Cmdlets.Tests/CopyChannelTests.cs index 6a1701f..b53354d 100644 --- a/Octopus-Cmdlets.Tests/CopyChannelTests.cs +++ b/Octopus-Cmdlets.Tests/CopyChannelTests.cs @@ -97,9 +97,9 @@ public void With_Project_And_Name() ChannelResource createdChannel = null; _octoRepo - .Setup(o => o.Channels.Create(It.IsAny(), null)) - .Callback(ch => createdChannel = ch) - .Returns(ch => ch); + .Setup(o => o.Channels.Create(It.IsAny(), It.IsAny())) + .Callback((ch, o) => createdChannel = ch) + .Returns((ch, o) => ch); // Execute cmdlet _ps.AddCommand(CmdletName) @@ -131,7 +131,7 @@ public void With_Invalid_Project() _ps.AddCommand(CmdletName) .AddParameter("Project", "Gibberish") .AddParameter("Name", "Priority"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -141,7 +141,7 @@ public void With_Project_And_Invalid_Name() _ps.AddCommand(CmdletName) .AddParameter("Project", "Octopus") .AddParameter("Name", "Default"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -150,9 +150,9 @@ public void With_Destination() ChannelResource createdChannel = null; _octoRepo - .Setup(o => o.Channels.Create(It.IsAny(), null)) - .Callback(ch => createdChannel = ch) - .Returns(ch => ch); + .Setup(o => o.Channels.Create(It.IsAny(), It.IsAny())) + .Callback((ch, o) => createdChannel = ch) + .Returns((ch, o) => ch); // Execute cmdlet _ps.AddCommand(CmdletName) @@ -184,9 +184,9 @@ public void With_Arguments() ChannelResource createdChannel = null; _octoRepo - .Setup(o => o.Channels.Create(It.IsAny(), null)) - .Callback(ch => createdChannel = ch) - .Returns(ch => ch); + .Setup(o => o.Channels.Create(It.IsAny(), It.IsAny())) + .Callback((ch, o) => createdChannel = ch) + .Returns((ch, o) => ch); // Execute cmdlet _ps.AddCommand(CmdletName) diff --git a/Octopus-Cmdlets.Tests/CopyProjectTests.cs b/Octopus-Cmdlets.Tests/CopyProjectTests.cs index f39321d..9bb76f7 100644 --- a/Octopus-Cmdlets.Tests/CopyProjectTests.cs +++ b/Octopus-Cmdlets.Tests/CopyProjectTests.cs @@ -47,8 +47,8 @@ public CopyProjectTests() octoRepo.Setup(o => o.Projects.FindByName("Source", null, null)).Returns(project); octoRepo.Setup(o => o.Projects.FindByName("Gibberish", null, null)).Returns((ProjectResource) null); - octoRepo.Setup(o => o.Projects.Create(It.IsAny(), null)).Returns( - delegate(ProjectResource p) + octoRepo.Setup(o => o.Projects.Create(It.IsAny(), It.IsAny())).Returns( + (ProjectResource p, object o) => { p.VariableSetId = "variablesets-2"; p.DeploymentProcessId = "deploymentprocesses-2"; @@ -112,13 +112,13 @@ public void With_All() var variable = _copyVariables.Variables.FirstOrDefault(x => x.Name == "Name" && x.Value == "Value"); Assert.NotNull(variable); Assert.True(variable.Scope.ContainsKey(ScopeField.Action)); - Assert.Equal(0, variable.Scope[ScopeField.Action].Count); + Assert.Empty(variable.Scope[ScopeField.Action]); Assert.True(variable.Scope.ContainsKey(ScopeField.Environment)); Assert.Equal("environments-1", variable.Scope[ScopeField.Environment].First()); var steps = _copyProcess.Steps.FirstOrDefault(x => x.Name == "Database"); Assert.NotNull(steps); - Assert.Equal(1, steps.Actions.Count); + Assert.Single(steps.Actions); Assert.Equal("Action", steps.Actions[0].Name); Assert.Equal("environments-1", steps.Actions[0].Environments.First()); } @@ -131,7 +131,7 @@ public void With_Invalid_Group() .AddParameter("Name", "Source") .AddParameter("Destination", "Copy") .AddParameter("ProjectGroup", "Gibberish"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -142,7 +142,7 @@ public void With_Invalid_Project() .AddParameter("Name", "Gibberish") .AddParameter("Destination", "Copy") .AddParameter("ProjectGroup", "Octopus"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] diff --git a/Octopus-Cmdlets.Tests/GetActionTests.cs b/Octopus-Cmdlets.Tests/GetActionTests.cs index fef3166..fa556f9 100644 --- a/Octopus-Cmdlets.Tests/GetActionTests.cs +++ b/Octopus-Cmdlets.Tests/GetActionTests.cs @@ -68,7 +68,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("Do Stuff"); var actions = _ps.Invoke(); - Assert.Equal(1, actions.Count); + Assert.Single(actions); Assert.Equal("Do Stuff", actions[0].Name); } @@ -79,7 +79,7 @@ public void With_Name_Parameter() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddParameter("Name", "Do Stuff"); var actions = _ps.Invoke(); - Assert.Equal(1, actions.Count); + Assert.Single(actions); Assert.Equal("Do Stuff", actions[0].Name); } @@ -90,7 +90,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("Gibberish"); var actions = _ps.Invoke(); - Assert.Equal(0, actions.Count); + Assert.Empty(actions); } [Fact] @@ -100,7 +100,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddParameter("Id", "Globally unique identifier"); var actions = _ps.Invoke(); - Assert.Equal(1, actions.Count); + Assert.Single(actions); Assert.Equal("Do Stuff", actions[0].Name); } @@ -111,7 +111,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddParameter("Id", "Gibberish"); var actions = _ps.Invoke(); - Assert.Equal(0, actions.Count); + Assert.Empty(actions); } } } diff --git a/Octopus-Cmdlets.Tests/GetDeploymentProcessTests.cs b/Octopus-Cmdlets.Tests/GetDeploymentProcessTests.cs index 9cf0887..d3342a3 100644 --- a/Octopus-Cmdlets.Tests/GetDeploymentProcessTests.cs +++ b/Octopus-Cmdlets.Tests/GetDeploymentProcessTests.cs @@ -49,7 +49,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "DeploymentProcesses-1"); var projects = _ps.Invoke(); - Assert.Equal(1, projects.Count); + Assert.Single(projects); } [Fact] @@ -59,7 +59,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "Gibberish"); var projects = _ps.Invoke(); - Assert.Equal(0, projects.Count); + Assert.Empty(projects); } [Fact] @@ -69,7 +69,7 @@ public void With_ProjectName() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus"); var projects = _ps.Invoke(); - Assert.Equal(1, projects.Count); + Assert.Single(projects); } [Fact] @@ -79,7 +79,7 @@ public void With_Invalid_ProjectName() _ps.AddCommand(CmdletName).AddParameter("Project", "Gibberish"); var projects = _ps.Invoke(); - Assert.Equal(0, projects.Count); + Assert.Empty(projects); } [Fact] @@ -89,7 +89,7 @@ public void With_Arguments() _ps.AddCommand(CmdletName).AddArgument("DeploymentProcesses-1"); var projects = _ps.Invoke(); - Assert.Equal(1, projects.Count); + Assert.Single(projects); } diff --git a/Octopus-Cmdlets.Tests/GetDeploymentTests.cs b/Octopus-Cmdlets.Tests/GetDeploymentTests.cs index 455fee5..09fc13c 100644 --- a/Octopus-Cmdlets.Tests/GetDeploymentTests.cs +++ b/Octopus-Cmdlets.Tests/GetDeploymentTests.cs @@ -61,7 +61,7 @@ public void With_Project_And_Release() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Release", "1.0.0"); var deployments = _ps.Invoke(); - Assert.Equal(1, deployments.Count); + Assert.Single(deployments); } [Fact] @@ -79,7 +79,7 @@ public void With_Project_And_Invalid_Release() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Release", "Gibberish"); var deployments = _ps.Invoke(); - Assert.Equal(0, deployments.Count); + Assert.Empty(deployments); } [Fact] @@ -97,7 +97,7 @@ public void With_ReleaseId() _ps.AddCommand(CmdletName).AddParameter("ReleaseId", "Releases-1"); var deployments = _ps.Invoke(); - Assert.Equal(1, deployments.Count); + Assert.Single(deployments); } [Fact] @@ -107,7 +107,7 @@ public void With_Arguments() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("1.0.0"); var deployments = _ps.Invoke(); - Assert.Equal(1, deployments.Count); + Assert.Single(deployments); } diff --git a/Octopus-Cmdlets.Tests/GetEnvironmentTests.cs b/Octopus-Cmdlets.Tests/GetEnvironmentTests.cs index c722fac..fe5fd41 100644 --- a/Octopus-Cmdlets.Tests/GetEnvironmentTests.cs +++ b/Octopus-Cmdlets.Tests/GetEnvironmentTests.cs @@ -44,7 +44,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); var environments = _ps.Invoke(); - Assert.Equal(1, environments.Count); + Assert.Single(environments); Assert.Equal("Octopus", environments[0].Name); } @@ -55,7 +55,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var environments = _ps.Invoke(); - Assert.Equal(0, environments.Count); + Assert.Empty(environments); } [Fact] @@ -65,7 +65,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "environments-1"); var environments = _ps.Invoke(); - Assert.Equal(1, environments.Count); + Assert.Single(environments); Assert.Equal("Octopus", environments[0].Name); } @@ -76,7 +76,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "Gibberish"); var environments = _ps.Invoke(); - Assert.Equal(0, environments.Count); + Assert.Empty(environments); } [Fact] @@ -86,7 +86,7 @@ public void With_ScopeValue() _ps.AddCommand(CmdletName).AddParameter("ScopeValue", new ScopeValue("environments-1")); var environments = _ps.Invoke(); - Assert.Equal(1, environments.Count); + Assert.Single(environments); Assert.Equal("Octopus", environments[0].Name); } @@ -97,7 +97,7 @@ public void With_Invalid_ScopeValue() _ps.AddCommand(CmdletName).AddParameter("ScopeValue", new ScopeValue("Gibberish")); var environments = _ps.Invoke(); - Assert.Equal(0, environments.Count); + Assert.Empty(environments); } [Fact] diff --git a/Octopus-Cmdlets.Tests/GetExternalFeedTests.cs b/Octopus-Cmdlets.Tests/GetExternalFeedTests.cs index d70e56b..9bc2037 100644 --- a/Octopus-Cmdlets.Tests/GetExternalFeedTests.cs +++ b/Octopus-Cmdlets.Tests/GetExternalFeedTests.cs @@ -55,7 +55,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); var feeds = _ps.Invoke(); - Assert.Equal(1, feeds.Count); + Assert.Single(feeds); Assert.Equal("Octopus", feeds[0].Name); } @@ -66,7 +66,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var feeds = _ps.Invoke(); - Assert.Equal(0, feeds.Count); + Assert.Empty(feeds); } } } diff --git a/Octopus-Cmdlets.Tests/GetMachineRoleTests.cs b/Octopus-Cmdlets.Tests/GetMachineRoleTests.cs index 13b454c..087b4a9 100644 --- a/Octopus-Cmdlets.Tests/GetMachineRoleTests.cs +++ b/Octopus-Cmdlets.Tests/GetMachineRoleTests.cs @@ -46,7 +46,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("WebServer"); var results = _ps.Invoke(); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("WebServer", results[0]); } @@ -57,7 +57,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var results = _ps.Invoke(); - Assert.Equal(0, results.Count); + Assert.Empty(results); } } } diff --git a/Octopus-Cmdlets.Tests/GetMachineTests.cs b/Octopus-Cmdlets.Tests/GetMachineTests.cs index 09e45c0..a3909af 100644 --- a/Octopus-Cmdlets.Tests/GetMachineTests.cs +++ b/Octopus-Cmdlets.Tests/GetMachineTests.cs @@ -50,7 +50,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddParameter("Name", new[] {"dbserver-01"}); var machines = _ps.Invoke(); - Assert.Equal(1, machines.Count); + Assert.Single(machines); Assert.Equal("dbserver-01", machines[0].Name); } @@ -61,7 +61,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddParameter("Name", new[] { "Gibberish" }); var machines = _ps.Invoke(); - Assert.Equal(0, machines.Count); + Assert.Empty(machines); } [Fact] @@ -71,7 +71,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", new[] { "Machines-1" }); var machines = _ps.Invoke(); - Assert.Equal(1, machines.Count); + Assert.Single(machines); Assert.Equal("dbserver-01", machines[0].Name); } @@ -82,7 +82,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", new[] { "Gibberish" }); var machines = _ps.Invoke(); - Assert.Equal(0, machines.Count); + Assert.Empty(machines); } [Fact] @@ -102,7 +102,7 @@ public void With_Arguments() _ps.AddCommand(CmdletName).AddArgument(new[] { "dbserver-01" }); var machines = _ps.Invoke(); - Assert.Equal(1, machines.Count); + Assert.Single(machines); Assert.Equal("dbserver-01", machines[0].Name); } } diff --git a/Octopus-Cmdlets.Tests/GetProjectGroupTests.cs b/Octopus-Cmdlets.Tests/GetProjectGroupTests.cs index f2f6325..09de2ff 100644 --- a/Octopus-Cmdlets.Tests/GetProjectGroupTests.cs +++ b/Octopus-Cmdlets.Tests/GetProjectGroupTests.cs @@ -44,7 +44,7 @@ where g.Name.Equals(n, StringComparison.InvariantCultureIgnoreCase) private static Func CreateGet(IEnumerable groupResources) { - return delegate(string id) + return (string id) => { var group = (from g in groupResources where g.Id.Equals(id, @@ -75,7 +75,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); var groups = _ps.Invoke(); - Assert.Equal(1, groups.Count); + Assert.Single(groups); Assert.Equal("Octopus", groups[0].Name); } @@ -86,7 +86,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var groups = _ps.Invoke(); - Assert.Equal(0, groups.Count); + Assert.Empty(groups); } [Fact] @@ -96,7 +96,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "projectgroups-1"); var groups = _ps.Invoke(); - Assert.Equal(1, groups.Count); + Assert.Single(groups); Assert.Equal("Octopus", groups[0].Name); } @@ -107,7 +107,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "gibberish"); var groups = _ps.Invoke(); - Assert.Equal(0, groups.Count); + Assert.Empty(groups); } } } diff --git a/Octopus-Cmdlets.Tests/GetProjectTests.cs b/Octopus-Cmdlets.Tests/GetProjectTests.cs index 79772e8..470d556 100644 --- a/Octopus-Cmdlets.Tests/GetProjectTests.cs +++ b/Octopus-Cmdlets.Tests/GetProjectTests.cs @@ -75,7 +75,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); var projects = _ps.Invoke(); - Assert.Equal(1, projects.Count); + Assert.Single(projects); Assert.Equal("Octopus", projects[0].Name); } @@ -86,7 +86,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var projects = _ps.Invoke(); - Assert.Equal(0, projects.Count); + Assert.Empty(projects); } [Fact] @@ -108,7 +108,7 @@ public void With_Invalid_Group() _ps.AddCommand(CmdletName).AddParameter("ProjectGroup", "Gibberish"); var projects = _ps.Invoke(); - Assert.Equal(0, projects.Count); + Assert.Empty(projects); } [Fact] @@ -118,7 +118,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "projects-1"); var projects = _ps.Invoke(); - Assert.Equal(1, projects.Count); + Assert.Single(projects); Assert.Equal("Octopus", projects[0].Name); } @@ -129,7 +129,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "projects-5000"); var projects = _ps.Invoke(); - Assert.Equal(0, projects.Count); + Assert.Empty(projects); } [Fact] diff --git a/Octopus-Cmdlets.Tests/GetReleaseTests.cs b/Octopus-Cmdlets.Tests/GetReleaseTests.cs index 2bd3cad..f58eeab 100644 --- a/Octopus-Cmdlets.Tests/GetReleaseTests.cs +++ b/Octopus-Cmdlets.Tests/GetReleaseTests.cs @@ -64,7 +64,7 @@ public void With_Invalid_Project() { // Execute cmdlet _ps.AddCommand(CmdletName).AddParameter("Project", "Gibberish"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -92,7 +92,7 @@ public void With_Project_And_Version() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Version", new[] {"1.0.0"}); var releases = _ps.Invoke(); - Assert.Equal(1, releases.Count); + Assert.Single(releases); Assert.Equal("1.0.0", releases[0].Version); } @@ -103,7 +103,7 @@ public void With_Project_And_Invalid_Version() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Version", new[] { "Gibberish" }); var releases = _ps.Invoke(); - Assert.Equal(0, releases.Count); + Assert.Empty(releases); } [Fact] @@ -113,7 +113,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "releases-1"); var releases = _ps.Invoke(); - Assert.Equal(1, releases.Count); + Assert.Single(releases); Assert.Equal("1.0.0", releases[0].Version); } @@ -124,7 +124,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "Gibberish"); var releases = _ps.Invoke(); - Assert.Equal(0, releases.Count); + Assert.Empty(releases); } } } diff --git a/Octopus-Cmdlets.Tests/GetStepTests.cs b/Octopus-Cmdlets.Tests/GetStepTests.cs index 86689c3..eb0be51 100644 --- a/Octopus-Cmdlets.Tests/GetStepTests.cs +++ b/Octopus-Cmdlets.Tests/GetStepTests.cs @@ -49,7 +49,7 @@ public void No_Arguments() { // Execute cmdlet _ps.AddCommand(CmdletName); - _ps.Invoke(); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -70,7 +70,7 @@ public void With_Invalid_ProjectName() _ps.AddCommand(CmdletName).AddParameter("Project", "Gibberish"); var steps = _ps.Invoke(); - Assert.Equal(0, steps.Count); + Assert.Empty(steps); } [Fact] @@ -91,7 +91,7 @@ public void With_Invalid_ProjectId() _ps.AddCommand(CmdletName).AddParameter("ProjectId", "Gibberish"); var steps = _ps.Invoke(); - Assert.Equal(0, steps.Count); + Assert.Empty(steps); } [Fact] @@ -112,7 +112,7 @@ public void With_Invalid_ProcessId() _ps.AddCommand(CmdletName).AddParameter("DeploymentProcessId", "Gibberish"); var steps = _ps.Invoke(); - Assert.Equal(0, steps.Count); + Assert.Empty(steps); } [Fact] @@ -122,7 +122,7 @@ public void With_ProjectAndName() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Name", "Test Step 2"); var steps = _ps.Invoke(); - Assert.Equal(1, steps.Count); + Assert.Single(steps); Assert.Equal("Test Step 2", steps[0].Name); } @@ -133,7 +133,7 @@ public void With_ProjectIdAndName() _ps.AddCommand(CmdletName).AddParameter("ProjectId", "projects-1").AddParameter("Name", "Test Step 2"); var steps = _ps.Invoke(); - Assert.Equal(1, steps.Count); + Assert.Single(steps); Assert.Equal("Test Step 2", steps[0].Name); } @@ -146,7 +146,7 @@ public void With_ProcessIdAndName() .AddParameter("Name", "Test Step 2"); var steps = _ps.Invoke(); - Assert.Equal(1, steps.Count); + Assert.Single(steps); Assert.Equal("Test Step 2", steps[0].Name); } @@ -158,20 +158,8 @@ public void With_Arguments() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("Test Step 2"); var steps = _ps.Invoke(); - Assert.Equal(1, steps.Count); + Assert.Single(steps); Assert.Equal("Test Step 2", steps[0].Name); } - - - [Fact] - public void With_KitchenSink() - { - // Execute cmdlet - _ps.AddCommand(CmdletName) - .AddParameter("Project", "Gibberish") - .AddParameter("ProjectId", "Gibberish") - .AddParameter("DeploymentProcessId", "Gibberish"); - _ps.Invoke(); - } } } diff --git a/Octopus-Cmdlets.Tests/GetVariableSetTests.cs b/Octopus-Cmdlets.Tests/GetVariableSetTests.cs index 494fbd9..c640161 100644 --- a/Octopus-Cmdlets.Tests/GetVariableSetTests.cs +++ b/Octopus-Cmdlets.Tests/GetVariableSetTests.cs @@ -62,7 +62,7 @@ public void With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("Octopus", variables[0].Name); } @@ -73,7 +73,7 @@ public void With_Invalid_Name() _ps.AddCommand(CmdletName).AddArgument("Gibberish"); var variables = _ps.Invoke(); - Assert.Equal(0, variables.Count); + Assert.Empty(variables); } [Fact] @@ -83,7 +83,7 @@ public void By_Name_With_Name() _ps.AddCommand(CmdletName).AddParameter("Name", "Octopus"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("Octopus", variables[0].Name); } @@ -94,7 +94,7 @@ public void With_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "LibraryVariableSets-1"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("Octopus", variables[0].Name); } @@ -105,7 +105,7 @@ public void With_Invalid_Id() _ps.AddCommand(CmdletName).AddParameter("Id", "Gibberish"); var variables = _ps.Invoke(); - Assert.Equal(0, variables.Count); + Assert.Empty(variables); } [Fact] diff --git a/Octopus-Cmdlets.Tests/GetVariableTests.cs b/Octopus-Cmdlets.Tests/GetVariableTests.cs index 1ffc46e..c151430 100644 --- a/Octopus-Cmdlets.Tests/GetVariableTests.cs +++ b/Octopus-Cmdlets.Tests/GetVariableTests.cs @@ -90,7 +90,7 @@ public void By_Project_With_Name() _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("Deploy"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("To Production", variables[0].Value); } @@ -119,7 +119,7 @@ public void With_Invalid_VariableSet() _ps.AddCommand(CmdletName).AddParameter("VariableSet", "Gibberish").AddArgument("Deploy"); _ps.Invoke(); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("Library variable set 'Gibberish' was not found.", _ps.Streams.Warning[0].ToString()); } @@ -130,7 +130,7 @@ public void By_VariableSet_With_Name() _ps.AddCommand(CmdletName).AddParameter("VariableSet", "Octopus").AddArgument("Deploy"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("To Production", variables[0].Value); } @@ -151,7 +151,7 @@ public void By_VariableSetId_With_Name() _ps.AddCommand(CmdletName).AddParameter("VariableSetId", "LibraryVariableSets-1").AddArgument("Deploy"); var variables = _ps.Invoke(); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("To Production", variables[0].Value); } @@ -162,7 +162,7 @@ public void With_Invalid_VariableSetId() _ps.AddCommand(CmdletName).AddParameter("VariableSetId", "Gibberish").AddArgument("Deploy"); _ps.Invoke(); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("Library variable set with id 'Gibberish' was not found.", _ps.Streams.Warning[0].ToString()); } } diff --git a/Octopus-Cmdlets.Tests/Octopus-Cmdlets.Tests.csproj b/Octopus-Cmdlets.Tests/Octopus-Cmdlets.Tests.csproj index 798b59f..6728caa 100644 --- a/Octopus-Cmdlets.Tests/Octopus-Cmdlets.Tests.csproj +++ b/Octopus-Cmdlets.Tests/Octopus-Cmdlets.Tests.csproj @@ -17,12 +17,13 @@ - - + + + - \ No newline at end of file + diff --git a/Octopus-Cmdlets.Tests/RemoveEnvironmentTests.cs b/Octopus-Cmdlets.Tests/RemoveEnvironmentTests.cs index 17da239..443fde7 100644 --- a/Octopus-Cmdlets.Tests/RemoveEnvironmentTests.cs +++ b/Octopus-Cmdlets.Tests/RemoveEnvironmentTests.cs @@ -32,7 +32,7 @@ public RemoveEnvironmentTests() _envs.Add(new EnvironmentResource { Id = "Environments-3", Name = "Prod" }); octoRepo.Setup(o => o.Environments.Delete(It.IsAny())).Callback( - delegate (EnvironmentResource set) + (EnvironmentResource set) => { if (_envs.Contains(set)) _envs.Remove(set); @@ -88,7 +88,7 @@ public void With_Id() _ps.Invoke(); Assert.Equal(2, _envs.Count); - Assert.False(_envs.Contains(_env)); + Assert.DoesNotContain(_env, _envs); } [Fact] @@ -99,7 +99,7 @@ public void With_Invalid_Id() _ps.Invoke(); Assert.Equal(3, _envs.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("An environment with the id 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -111,7 +111,7 @@ public void With_Name() _ps.Invoke(); Assert.Equal(2, _envs.Count); - Assert.False(_envs.Contains(_env)); + Assert.DoesNotContain(_env, _envs); } [Fact] @@ -122,7 +122,7 @@ public void With_Invalid_Name() _ps.Invoke(); Assert.Equal(3, _envs.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The environment 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -134,7 +134,7 @@ public void With_Valid_And_Invalid_Names() _ps.Invoke(); Assert.Equal(2, _envs.Count); - Assert.False(_envs.Contains(_env)); + Assert.DoesNotContain(_env, _envs); } [Fact] @@ -145,7 +145,7 @@ public void With_Arguments() _ps.Invoke(); Assert.Equal(2, _envs.Count); - Assert.False(_envs.Contains(_env)); + Assert.DoesNotContain(_env, _envs); } [Fact] diff --git a/Octopus-Cmdlets.Tests/RemoveProjectGroupTests.cs b/Octopus-Cmdlets.Tests/RemoveProjectGroupTests.cs index fd76a73..e498855 100644 --- a/Octopus-Cmdlets.Tests/RemoveProjectGroupTests.cs +++ b/Octopus-Cmdlets.Tests/RemoveProjectGroupTests.cs @@ -32,7 +32,7 @@ public RemoveProjectGroupTests() _groups.Add(new ProjectGroupResource { Id = "ProjectGroups-3", Name = "Automation" }); octoRepo.Setup(o => o.ProjectGroups.Delete(It.IsAny())).Callback( - delegate (ProjectGroupResource set) + (ProjectGroupResource set) => { if (_groups.Contains(set)) _groups.Remove(set); @@ -88,7 +88,7 @@ public void With_Id() _ps.Invoke(); Assert.Equal(2, _groups.Count); - Assert.False(_groups.Contains(_group)); + Assert.DoesNotContain(_group, _groups); } [Fact] @@ -99,7 +99,7 @@ public void With_Invalid_Id() _ps.Invoke(); Assert.Equal(3, _groups.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("A project group with the id 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -111,7 +111,7 @@ public void With_Name() _ps.Invoke(); Assert.Equal(2, _groups.Count); - Assert.False(_groups.Contains(_group)); + Assert.DoesNotContain(_group, _groups); } [Fact] @@ -122,7 +122,7 @@ public void With_Invalid_Name() _ps.Invoke(); Assert.Equal(3, _groups.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The project group 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -134,7 +134,7 @@ public void With_Valid_And_Invalid_Names() _ps.Invoke(); Assert.Equal(2, _groups.Count); - Assert.False(_groups.Contains(_group)); + Assert.DoesNotContain(_group, _groups); } [Fact] @@ -145,7 +145,7 @@ public void With_Arguments() _ps.Invoke(); Assert.Equal(2, _groups.Count); - Assert.False(_groups.Contains(_group)); + Assert.DoesNotContain(_group, _groups); } [Fact] diff --git a/Octopus-Cmdlets.Tests/RemoveProjectTests.cs b/Octopus-Cmdlets.Tests/RemoveProjectTests.cs index 80b92bc..a8fab40 100644 --- a/Octopus-Cmdlets.Tests/RemoveProjectTests.cs +++ b/Octopus-Cmdlets.Tests/RemoveProjectTests.cs @@ -32,7 +32,7 @@ public RemoveProjectTests() _projects.Add(new ProjectResource { Id = "Projects-3", Name = "Automation" }); octoRepo.Setup(o => o.Projects.Delete(It.IsAny())).Callback( - delegate (ProjectResource set) + (ProjectResource set) => { if (_projects.Contains(set)) _projects.Remove(set); @@ -88,7 +88,7 @@ public void With_Id() _ps.Invoke(); Assert.Equal(2, _projects.Count); - Assert.False(_projects.Contains(_project)); + Assert.DoesNotContain(_project, _projects); } [Fact] @@ -99,7 +99,7 @@ public void With_Invalid_Id() _ps.Invoke(); Assert.Equal(3, _projects.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("A project with the id 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -111,7 +111,7 @@ public void With_Name() _ps.Invoke(); Assert.Equal(2, _projects.Count); - Assert.False(_projects.Contains(_project)); + Assert.DoesNotContain(_project, _projects); } [Fact] @@ -122,7 +122,7 @@ public void With_Invalid_Name() _ps.Invoke(); Assert.Equal(3, _projects.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The project 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -134,7 +134,7 @@ public void With_Valid_And_Invalid_Names() _ps.Invoke(); Assert.Equal(2, _projects.Count); - Assert.False(_projects.Contains(_project)); + Assert.DoesNotContain(_project, _projects); } [Fact] @@ -145,7 +145,7 @@ public void With_Arguments() _ps.Invoke(); Assert.Equal(2, _projects.Count); - Assert.False(_projects.Contains(_project)); + Assert.DoesNotContain(_project, _projects); } [Fact] diff --git a/Octopus-Cmdlets.Tests/RemoveVariableSetTests.cs b/Octopus-Cmdlets.Tests/RemoveVariableSetTests.cs index 7771a9d..e152db9 100644 --- a/Octopus-Cmdlets.Tests/RemoveVariableSetTests.cs +++ b/Octopus-Cmdlets.Tests/RemoveVariableSetTests.cs @@ -33,7 +33,8 @@ public RemoveVariableSetTests() _sets.Add(_set); _sets.Add(new LibraryVariableSetResource {Id = "LibraryVariableSets-3", Name = "Service Endpoints"}); - octoRepo.Setup(o => o.LibraryVariableSets.Delete(It.IsAny())).Callback(delegate (LibraryVariableSetResource set) + octoRepo.Setup(o => o.LibraryVariableSets.Delete(It.IsAny())).Callback( + (LibraryVariableSetResource set) => { if (_sets.Contains(set)) _sets.Remove(set); @@ -69,7 +70,7 @@ public void With_Object() _ps.Invoke(); Assert.Equal(2, _sets.Count); - Assert.False(_sets.Contains(_set)); + Assert.DoesNotContain(_set, _sets); } [Fact] @@ -80,7 +81,7 @@ public void With_Invalid_Object() _ps.Invoke(); Assert.Equal(3, _sets.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The library variable set '' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -92,7 +93,7 @@ public void With_Id() _ps.Invoke(); Assert.Equal(2, _sets.Count); - Assert.False(_sets.Contains(_set)); + Assert.DoesNotContain(_set, _sets); } [Fact] @@ -103,7 +104,7 @@ public void With_Invalid_Id() _ps.Invoke(); Assert.Equal(3, _sets.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The library variable set with id 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -115,7 +116,7 @@ public void With_Name() _ps.Invoke(); Assert.Equal(2, _sets.Count); - Assert.False(_sets.Contains(_set)); + Assert.DoesNotContain(_set, _sets); } [Fact] @@ -126,7 +127,7 @@ public void With_Invalid_Name() _ps.Invoke(); Assert.Equal(3, _sets.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("The library variable set 'Gibberish' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -138,7 +139,7 @@ public void With_Arguments() _ps.Invoke(); Assert.Equal(2, _sets.Count); - Assert.False(_sets.Contains(_set)); + Assert.DoesNotContain(_set, _sets); } [Fact] diff --git a/Octopus-Cmdlets.Tests/RemoveVariableTests.cs b/Octopus-Cmdlets.Tests/RemoveVariableTests.cs index 5375dd9..a0b6484 100644 --- a/Octopus-Cmdlets.Tests/RemoveVariableTests.cs +++ b/Octopus-Cmdlets.Tests/RemoveVariableTests.cs @@ -62,7 +62,7 @@ public void With_Invalid_Object() _ps.Invoke(); Assert.Equal(3, _variableSet.Variables.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("Variable '' in project 'Octopus' does not exist.", _ps.Streams.Warning[0].ToString()); } @@ -108,7 +108,7 @@ public void With_Invalid_Name() _ps.Invoke(); Assert.Equal(3, _variableSet.Variables.Count); - Assert.Equal(1, _ps.Streams.Warning.Count); + Assert.Single(_ps.Streams.Warning); Assert.Equal("Variable 'Gibberish' in project 'Octopus' does not exist.", _ps.Streams.Warning[0].ToString()); } diff --git a/Octopus-Cmdlets.Tests/UpdateLibraryVariableTests.cs b/Octopus-Cmdlets.Tests/UpdateLibraryVariableTests.cs index 6273f5d..60b3269 100644 --- a/Octopus-Cmdlets.Tests/UpdateLibraryVariableTests.cs +++ b/Octopus-Cmdlets.Tests/UpdateLibraryVariableTests.cs @@ -116,7 +116,7 @@ public void With_Sensitive() _ps.AddCommand(CmdletName).AddParameter("VariableSet", "ConnectionStrings").AddParameter("Id", "variables-1").AddParameter("Sensitive", true); _ps.Invoke(); - Assert.Equal(true, _variableSet.Variables[0].IsSensitive); + Assert.True(_variableSet.Variables[0].IsSensitive); } [Fact] @@ -163,7 +163,7 @@ public void With_All() Assert.Equal(1, _variableSet.Variables.Count); Assert.Equal("NewName", _variableSet.Variables[0].Name); Assert.Equal("New Test Value", _variableSet.Variables[0].Value); - Assert.Equal(true, _variableSet.Variables[0].IsSensitive); + Assert.True(_variableSet.Variables[0].IsSensitive); Assert.Equal("environments-2", _variableSet.Variables[0].Scope[ScopeField.Environment].First()); Assert.Equal("Web", _variableSet.Variables[0].Scope[ScopeField.Role].First()); Assert.Equal("machines-2", _variableSet.Variables[0].Scope[ScopeField.Machine].First()); diff --git a/Octopus-Cmdlets.Tests/UpdateVariableTests.cs b/Octopus-Cmdlets.Tests/UpdateVariableTests.cs index 825eba9..c6be7a9 100644 --- a/Octopus-Cmdlets.Tests/UpdateVariableTests.cs +++ b/Octopus-Cmdlets.Tests/UpdateVariableTests.cs @@ -108,7 +108,7 @@ public void With_Sensitive() _ps.AddCommand(CmdletName).AddParameter("Project", "Octopus").AddParameter("Id", "variables-1").AddParameter("Sensitive", true); _ps.Invoke(); - Assert.Equal(true, _variableSet.Variables[0].IsSensitive); + Assert.True(_variableSet.Variables[0].IsSensitive); } [Fact] @@ -155,7 +155,7 @@ public void With_All() Assert.Equal(1, _variableSet.Variables.Count); Assert.Equal("NewName", _variableSet.Variables[0].Name); Assert.Equal("New Test Value", _variableSet.Variables[0].Value); - Assert.Equal(true, _variableSet.Variables[0].IsSensitive); + Assert.True(_variableSet.Variables[0].IsSensitive); Assert.Equal("environments-2", _variableSet.Variables[0].Scope[ScopeField.Environment].First()); Assert.Equal("Web", _variableSet.Variables[0].Scope[ScopeField.Role].First()); Assert.Equal("machines-2", _variableSet.Variables[0].Scope[ScopeField.Machine].First()); diff --git a/Octopus-Cmdlets.Tests/UseVariableSetTests.cs b/Octopus-Cmdlets.Tests/UseVariableSetTests.cs index 3384b3c..4de21d9 100644 --- a/Octopus-Cmdlets.Tests/UseVariableSetTests.cs +++ b/Octopus-Cmdlets.Tests/UseVariableSetTests.cs @@ -58,7 +58,7 @@ public void With_Invalid_Project() { // Execute cmdlet _ps.AddCommand(CmdletName).AddArgument("Gibberish").AddArgument("ConnectionStrings"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } [Fact] @@ -76,7 +76,7 @@ public void With_Name() { // Execute cmdlet _ps.AddCommand(CmdletName).AddArgument("Octopus").AddArgument("Gibberish"); - Assert.Throws(() => _ps.Invoke()); + Assert.Throws(() => _ps.Invoke()); } } } diff --git a/Octopus-Cmdlets/AddEnvironment.cs b/Octopus-Cmdlets/AddEnvironment.cs index debeca5..99cc94b 100644 --- a/Octopus-Cmdlets/AddEnvironment.cs +++ b/Octopus-Cmdlets/AddEnvironment.cs @@ -77,7 +77,7 @@ protected override void ProcessRecord() { Name = Name, Description = Description - }); + }, null); } } } diff --git a/Octopus-Cmdlets/AddNugetFeed.cs b/Octopus-Cmdlets/AddNugetFeed.cs index 1c62804..506cc5c 100644 --- a/Octopus-Cmdlets/AddNugetFeed.cs +++ b/Octopus-Cmdlets/AddNugetFeed.cs @@ -31,7 +31,7 @@ namespace Octopus_Cmdlets /// /// /// - /// PS C:\>add-octonugetfeed -Name DEV -Uri "\\test" + /// PS C:\>add-octonugetfeed -Name DEV -FeedUri "\\test" /// /// Add a new feed named 'DEV' pointing to the path '\\test'. /// @@ -47,6 +47,15 @@ public class AddNugetFeed : PSCmdlet Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] + public string Name { get; set; } + + /// + /// The URI of the feed to create. + /// + [Parameter( + Position = 1, + Mandatory = false, + ValueFromPipelineByPropertyName = true)] public string FeedUri { get; set; } [Parameter] @@ -81,6 +90,7 @@ protected override void ProcessRecord() { _octopus.Feeds.Create(new NuGetFeedResource { + Name = Name, FeedUri = FeedUri, Username = Username, Password = Password, diff --git a/README.md b/README.md index 67ae3e9..a610d9f 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ can automate while you automate. Octopus-Cmdlets is a suite of PowerShell cmdlets that enable you to simplify and automate your interactions with an Octopus Deploy server. -Automate all the things!!! - Note ==== The module name has changed from `Octopus.Cmdlets` to `Octopus-Cmdlets`. Please @@ -22,13 +20,6 @@ Powershell Gallery (preferred method) Install-Module -Name Octopus-Cmdlets -PsGet ------ -If you don't already have PsGet, install it from https://github.com/psget/psget - -To install Octopus-Cmdlets run - - install-module Octopus-Cmdlets Binary Archive -------------- @@ -66,6 +57,6 @@ description of the individual cmdlets, or type `help [cmdlet]` from PowerShell. Licence ======= -Copyright 2014 Colin Svingen +Copyright 2018 Colin Svingen Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) diff --git a/Version.cs b/Version.cs index f1f29d8..4ab3645 100644 --- a/Version.cs +++ b/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("0.4.5.0")] -[assembly: AssemblyFileVersion("0.4.5.0")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.0.0")] +[assembly: AssemblyFileVersion("0.5.0.0")] \ No newline at end of file