Skip to content

Commit d639550

Browse files
committed
Fixing minor test issues
1 parent 8a36c7a commit d639550

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

src/ResourceManager/Insights/Commands.Insights.Test/ActionGroups/GetAzureRmActionGroupCommandTests.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,8 @@ public void GetActionGroupCommandParametersProcessing()
109109
// Error
110110
cmdlet.ResourceGroupName = " ";
111111
cmdlet.Name = Utilities.Name;
112-
try
113-
{
114-
cmdlet.ExecuteCmdlet();
115-
Assert.True(false, "Did not throw exception");
116-
}
117-
catch (PSInvalidOperationException ex)
118-
{
119-
string message = ex.ToString();
120-
Assert.True(message.Contains("PSArgumentException"), "Wrong exception thrown");
121-
}
112+
var argException = Assert.Throws<PSInvalidOperationException>(() => cmdlet.ExecuteCmdlet());
113+
Assert.Contains("PSArgumentException", argException.ToString());
122114
}
123115
}
124116
}

src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,8 @@ public void SetSomeCategories()
209209
cmdlet.Categories = new List<string> { "TestCategory3" };
210210
cmdlet.Enabled = false;
211211
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
212-
213-
try
214-
{
215-
cmdlet.ExecuteCmdlet();
216-
Assert.True(false, "Did not throw exception");
217-
}
218-
catch (PSInvalidOperationException ex)
219-
{
220-
string message = ex.ToString();
221-
Assert.True(message.Contains("ArgumentException"), "Not the right type of exception");
222-
}
212+
var argException = Assert.Throws<PSInvalidOperationException>(() => cmdlet.ExecuteCmdlet());
213+
Assert.Contains("ArgumentException", argException.ToString());
223214

224215
// Testing the new metric categories must be known before the cmdlet can add them
225216
expectedSettings.Metrics[0].Enabled = false;
@@ -235,16 +226,8 @@ public void SetSomeCategories()
235226
cmdlet.MetricCategory = new List<string> { "MetricCat3" };
236227
cmdlet.Enabled = false;
237228
cmdlet.MyInvocation.BoundParameters[SetAzureRmDiagnosticSettingCommand.EnabledParamName] = false;
238-
try
239-
{
240-
cmdlet.ExecuteCmdlet();
241-
Assert.True(false, "Did not throw exception #2");
242-
}
243-
catch (PSInvalidOperationException ex)
244-
{
245-
string message = ex.ToString();
246-
Assert.True(message.Contains("ArgumentException"), "Not the right type of exception #2");
247-
}
229+
argException = Assert.Throws<PSInvalidOperationException>(() => cmdlet.ExecuteCmdlet());
230+
Assert.Contains("ArgumentException", argException.ToString());
248231
}
249232

250233
[Fact]

src/ResourceManager/Insights/Commands.Insights.Test/ScenarioTests/ActionGroupsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ActionGroupsTests(Xunit.Abstractions.ITestOutputHelper output)
3030
XunitTracingInterceptor.AddToContext(_logger);
3131
}
3232

33-
[Fact(Skip = "Needs to be recorded again")]
33+
[Fact(Skip = "TODO: #7024: Needs to be recorded again")]
3434
[Trait(Category.AcceptanceType, Category.CheckIn)]
3535
public void TestAddGetListSetRemoveActionGroup()
3636
{

0 commit comments

Comments
 (0)