Skip to content

Commit

Permalink
Adds nameof() to some of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Swoogan committed Sep 25, 2018
1 parent d763340 commit 444be32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
10 changes: 6 additions & 4 deletions Octopus-Cmdlets.Tests/AddEnvironmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public AddEnvironmentTests()
public void With_Name()
{
// Execute cmdlet
_ps.AddCommand(CmdletName).AddParameter("Name", "Octopus_Dev");
_ps.AddCommand(CmdletName)
.AddParameter(nameof(AddEnvironment.Name), "Octopus_Dev");
_ps.Invoke();

Assert.Single(_envs);
Expand All @@ -46,7 +47,8 @@ public void With_Name()
public void With_Description()
{
// Execute cmdlet
_ps.AddCommand(CmdletName).AddParameter("Description", "Octopus Development environment");
_ps.AddCommand(CmdletName)
.AddParameter(nameof(AddEnvironment.Description), "Octopus Development environment");
Assert.Throws<ParameterBindingException>(() => _ps.Invoke());
}

Expand All @@ -55,8 +57,8 @@ public void With_Name_And_Description()
{
// Execute cmdlet
_ps.AddCommand(CmdletName).
AddParameter("Name", "Octopus_Dev").
AddParameter("Description", "Octopus Development environment");
AddParameter(nameof(AddEnvironment.Name), "Octopus_Dev").
AddParameter(nameof(AddEnvironment.Description), "Octopus Development environment");
_ps.Invoke();

Assert.Single(_envs);
Expand Down
26 changes: 15 additions & 11 deletions Octopus-Cmdlets.Tests/AddLibraryVariableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void No_Arguments()
public void With_Name()
{
// Execute cmdlet
_ps.AddCommand(CmdletName).AddParameter("VariableSet", "Octopus").AddParameter("Name", "Test");
_ps.AddCommand(CmdletName)
.AddParameter(nameof(AddLibraryVariable.VariableSet), "Octopus")
.AddParameter(nameof(AddLibraryVariable.Name), "Test");
_ps.Invoke();

Assert.Equal(1, _variableSet.Variables.Count);
Expand All @@ -73,7 +75,9 @@ public void With_Name()
public void With_Invalid_VariableSet()
{
// Execute cmdlet
_ps.AddCommand(CmdletName).AddParameter("VariableSet", "Gibberish").AddParameter("Name", "Test");
_ps.AddCommand(CmdletName)
.AddParameter(nameof(AddLibraryVariable.VariableSet), "Gibberish")
.AddParameter(nameof(AddLibraryVariable.Name), "Test");
Assert.Throws<CmdletInvocationException>(() => _ps.Invoke());
}

Expand All @@ -82,13 +86,13 @@ public void With_All()
{
// Execute cmdlet
_ps.AddCommand(CmdletName)
.AddParameter("VariableSet", "Octopus")
.AddParameter("Name", "Test")
.AddParameter("Value", "Test Value")
.AddParameter("Environments", new[] { "DEV" })
.AddParameter("Roles", new[] { "Web" })
.AddParameter("Machines", new[] { "web-01" })
.AddParameter("Sensitive", false);
.AddParameter(nameof(AddLibraryVariable.VariableSet), "Octopus")
.AddParameter(nameof(AddLibraryVariable.Name), "Test")
.AddParameter(nameof(AddLibraryVariable.Value), "Test Value")
.AddParameter(nameof(AddLibraryVariable.Environments), new[] { "DEV" })
.AddParameter(nameof(AddLibraryVariable.Roles), new[] { "Web" })
.AddParameter(nameof(AddLibraryVariable.Machines), new[] { "web-01" })
.AddParameter(nameof(AddLibraryVariable.Sensitive), false);
_ps.Invoke();

Assert.Equal(1, _variableSet.Variables.Count);
Expand All @@ -101,8 +105,8 @@ public void With_Object()
{
// Execute cmdlet
_ps.AddCommand(CmdletName)
.AddParameter("VariableSet", "Octopus")
.AddParameter("InputObject", new VariableResource { Name = "Test" });
.AddParameter(nameof(AddLibraryVariable.VariableSet), "Octopus")
.AddParameter(nameof(AddLibraryVariable.InputObject), new VariableResource { Name = "Test" });
_ps.Invoke();

Assert.Equal(1, _variableSet.Variables.Count);
Expand Down

0 comments on commit 444be32

Please sign in to comment.