Update assertions to use ThrowsExactly

This commit is contained in:
Michael Bucari-Tovo 2025-08-14 15:58:01 -06:00
parent 05fad01624
commit ceb007500d
2 changed files with 8 additions and 8 deletions

View File

@ -528,7 +528,7 @@ namespace AccountsTests
var a2 = new Account("a") { AccountName = "two", IdentityTokens = idIn }; var a2 = new Account("a") { AccountName = "two", IdentityTokens = idIn };
// violation: validate() // violation: validate()
Assert.ThrowsException<InvalidOperationException>(() => accountsSettings.Add(a2)); Assert.ThrowsExactly<InvalidOperationException>(() => accountsSettings.Add(a2));
} }
[TestMethod] [TestMethod]
@ -545,7 +545,7 @@ namespace AccountsTests
accountsSettings.Add(a2); accountsSettings.Add(a2);
// violation: GetAccount.SingleOrDefault // violation: GetAccount.SingleOrDefault
Assert.ThrowsException<InvalidOperationException>(() => a2.IdentityTokens = idIn); Assert.ThrowsExactly<InvalidOperationException>(() => a2.IdentityTokens = idIn);
} }
} }

View File

@ -17,7 +17,7 @@ namespace FileUtilityTests
static readonly ReplacementCharacters Barebones = ReplacementCharacters.Barebones(Environment.OSVersion.Platform == PlatformID.Win32NT); static readonly ReplacementCharacters Barebones = ReplacementCharacters.Barebones(Environment.OSVersion.Platform == PlatformID.Win32NT);
[TestMethod] [TestMethod]
public void null_path_throws() => Assert.ThrowsException<ArgumentNullException>(() => FileUtility.GetSafePath(null, Default)); public void null_path_throws() => Assert.ThrowsExactly<ArgumentNullException>(() => FileUtility.GetSafePath(null, Default));
[TestMethod] [TestMethod]
// non-empty replacement // non-empty replacement
@ -137,25 +137,25 @@ namespace FileUtilityTests
public class GetSequenceFormatted public class GetSequenceFormatted
{ {
[TestMethod] [TestMethod]
public void negative_partsPosition() => Assert.ThrowsException<ArgumentException>(() public void negative_partsPosition() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(-1, 2) => FileUtility.GetSequenceFormatted(-1, 2)
); );
[TestMethod] [TestMethod]
public void zero_partsPosition() => Assert.ThrowsException<ArgumentException>(() public void zero_partsPosition() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(0, 2) => FileUtility.GetSequenceFormatted(0, 2)
); );
[TestMethod] [TestMethod]
public void negative_partsTotal() => Assert.ThrowsException<ArgumentException>(() public void negative_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, -1) => FileUtility.GetSequenceFormatted(2, -1)
); );
[TestMethod] [TestMethod]
public void zero_partsTotal() => Assert.ThrowsException<ArgumentException>(() public void zero_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, 0) => FileUtility.GetSequenceFormatted(2, 0)
); );
[TestMethod] [TestMethod]
public void partsPosition_greater_than_partsTotal() => Assert.ThrowsException<ArgumentException>(() public void partsPosition_greater_than_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, 1) => FileUtility.GetSequenceFormatted(2, 1)
); );