diff --git a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
index 04243a107..3899341d0 100644
--- a/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
+++ b/tests/CommunityToolkit.Common.UnitTests/CommunityToolkit.Common.UnitTests.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_ArrayExtensions.cs b/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_ArrayExtensions.cs
index 35a2a5144..fd2813693 100644
--- a/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_ArrayExtensions.cs
+++ b/tests/CommunityToolkit.Common.UnitTests/Extensions/Test_ArrayExtensions.cs
@@ -37,12 +37,12 @@ public void Test_ArrayExtensions_Jagged_GetColumn_Exception()
new int[] { 7 }
};
- _ = Assert.ThrowsException(() =>
+ _ = Assert.ThrowsExactly(() =>
{
_ = array.GetColumn(-1).ToArray();
});
- _ = Assert.ThrowsException(() =>
+ _ = Assert.ThrowsExactly(() =>
{
_ = array.GetColumn(3).ToArray();
});
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
index 7135ee3eb..97eca8abe 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/CommunityToolkit.Diagnostics.UnitTests.csproj
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.Array.cs b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.Array.cs
index d571105ae..41997cdcb 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.Array.cs
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.Array.cs
@@ -16,10 +16,9 @@ public void Test_Guard_IsEmpty_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsEmpty_ArrayFail()
{
- Guard.IsEmpty(new int[1], nameof(Test_Guard_IsEmpty_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.IsEmpty(new int[1], nameof(Test_Guard_IsEmpty_ArrayFail)));
}
[TestMethod]
@@ -29,10 +28,9 @@ public void Test_Guard_IsNotEmpty_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsNotEmpty_ArrayFail()
{
- Guard.IsNotEmpty(new int[0], nameof(Test_Guard_IsNotEmpty_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.IsNotEmpty(new int[0], nameof(Test_Guard_IsNotEmpty_ArrayFail)));
}
[TestMethod]
@@ -42,10 +40,9 @@ public void Test_Guard_HasSizeEqualTo_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeEqualTo_ArrayFail()
{
- Guard.HasSizeEqualTo(new int[3], 4, nameof(Test_Guard_HasSizeEqualTo_ArrayOk));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeEqualTo(new int[3], 4, nameof(Test_Guard_HasSizeEqualTo_ArrayOk)));
}
[TestMethod]
@@ -55,10 +52,9 @@ public void Test_Guard_HasSizeNotEqualTo_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeNotEqualTo_ArrayFail()
{
- Guard.HasSizeNotEqualTo(new int[4], 4, nameof(Test_Guard_HasSizeNotEqualTo_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeNotEqualTo(new int[4], 4, nameof(Test_Guard_HasSizeNotEqualTo_ArrayFail)));
}
[TestMethod]
@@ -68,17 +64,15 @@ public void Test_Guard_HasSizeGreaterThan_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeGreaterThan_ArrayEqualFail()
{
- Guard.HasSizeGreaterThan(new int[4], 4, nameof(Test_Guard_HasSizeGreaterThan_ArrayEqualFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeGreaterThan(new int[4], 4, nameof(Test_Guard_HasSizeGreaterThan_ArrayEqualFail)));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeGreaterThan_ArraySmallerFail()
{
- Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThan_ArraySmallerFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThan_ArraySmallerFail)));
}
[TestMethod]
@@ -89,10 +83,9 @@ public void Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayFail()
{
- Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayFail)));
}
[TestMethod]
@@ -102,17 +95,15 @@ public void Test_Guard_HasSizeLessThan_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeLessThan_ArrayEqualFail()
{
- Guard.HasSizeLessThan(new int[4], 4, nameof(Test_Guard_HasSizeLessThan_ArrayEqualFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeLessThan(new int[4], 4, nameof(Test_Guard_HasSizeLessThan_ArrayEqualFail)));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeLessThan_ArrayGreaterFail()
{
- Guard.HasSizeLessThan(new int[6], 4, nameof(Test_Guard_HasSizeLessThan_ArrayGreaterFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeLessThan(new int[6], 4, nameof(Test_Guard_HasSizeLessThan_ArrayGreaterFail)));
}
[TestMethod]
@@ -123,10 +114,9 @@ public void Test_Guard_HasSizeLessThanOrEqualTo_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeLessThanOrEqualTo_ArrayFail()
{
- Guard.HasSizeLessThanOrEqualTo(new int[8], 4, nameof(Test_Guard_HasSizeLessThanOrEqualTo_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeLessThanOrEqualTo(new int[8], 4, nameof(Test_Guard_HasSizeLessThanOrEqualTo_ArrayFail)));
}
[TestMethod]
@@ -136,10 +126,9 @@ public void Test_Guard_HasSizeEqualToArray_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeEqualToArray_ArrayFail()
{
- Guard.HasSizeEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeEqualToArray_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeEqualToArray_ArrayFail)));
}
[TestMethod]
@@ -150,9 +139,8 @@ public void Test_Guard_HasSizeLessThanOrEqualToArray_ArrayOk()
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_HasSizeLessThanOrEqualToArray_ArrayFail()
{
- Guard.HasSizeLessThanOrEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeLessThanOrEqualToArray_ArrayFail));
+ _ = Assert.ThrowsExactly(() => Guard.HasSizeLessThanOrEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeLessThanOrEqualToArray_ArrayFail)));
}
}
diff --git a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
index 482df6fe8..7cbe156a9 100644
--- a/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
+++ b/tests/CommunityToolkit.Diagnostics.UnitTests/Test_Guard.cs
@@ -26,21 +26,18 @@ static void Test(T? obj)
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsNull_ClassFail()
{
- Guard.IsNull(new object(), nameof(Test_Guard_IsNull_ClassFail));
+ _ = Assert.ThrowsExactly(() => Guard.IsNull(new object(), nameof(Test_Guard_IsNull_ClassFail)));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsNull_StructFail()
{
- Guard.IsNull(7, nameof(Test_Guard_IsNull_StructFail));
+ _ = Assert.ThrowsExactly(() => Guard.IsNull(7, nameof(Test_Guard_IsNull_StructFail)));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsNull_GenericClassFail()
{
static void Test(T? obj)
@@ -48,11 +45,10 @@ static void Test(T? obj)
Guard.IsNull(obj, nameof(Test_Guard_IsNull_GenericClassFail));
}
- Test("Hi!");
+ _ = Assert.ThrowsExactly(() => Test("Hi!"));
}
[TestMethod]
- [ExpectedException(typeof(ArgumentException))]
public void Test_Guard_IsNull_GenericStructFail()
{
static void Test(T? obj)
@@ -60,7 +56,7 @@ static void Test(T? obj)
Guard.IsNull(obj, nameof(Test_Guard_IsNull_GenericStructFail));
}
- Test(42);
+ _ = Assert.ThrowsExactly(() => Test(42));
}
[TestMethod]
@@ -80,21 +76,18 @@ static void Test(T? obj)
}
[TestMethod]
- [ExpectedException(typeof(ArgumentNullException))]
public void Test_Guard_IsNotNull_ClassFail()
{
- Guard.IsNotNull