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 };
// violation: validate()
Assert.ThrowsException<InvalidOperationException>(() => accountsSettings.Add(a2));
Assert.ThrowsExactly<InvalidOperationException>(() => accountsSettings.Add(a2));
}
[TestMethod]
@ -545,7 +545,7 @@ namespace AccountsTests
accountsSettings.Add(a2);
// 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);
[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]
// non-empty replacement
@ -137,25 +137,25 @@ namespace FileUtilityTests
public class GetSequenceFormatted
{
[TestMethod]
public void negative_partsPosition() => Assert.ThrowsException<ArgumentException>(()
public void negative_partsPosition() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(-1, 2)
);
[TestMethod]
public void zero_partsPosition() => Assert.ThrowsException<ArgumentException>(()
public void zero_partsPosition() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(0, 2)
);
[TestMethod]
public void negative_partsTotal() => Assert.ThrowsException<ArgumentException>(()
public void negative_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, -1)
);
[TestMethod]
public void zero_partsTotal() => Assert.ThrowsException<ArgumentException>(()
public void zero_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, 0)
);
[TestMethod]
public void partsPosition_greater_than_partsTotal() => Assert.ThrowsException<ArgumentException>(()
public void partsPosition_greater_than_partsTotal() => Assert.ThrowsExactly<ArgumentException>(()
=> FileUtility.GetSequenceFormatted(2, 1)
);