diff --git a/src/libraries/System.Collections/tests/Generic/CollectionExtensionsTests.cs b/src/libraries/System.Collections/tests/Generic/CollectionExtensionsTests.cs index e19de45a151..33e17147a99 100644 --- a/src/libraries/System.Collections/tests/Generic/CollectionExtensionsTests.cs +++ b/src/libraries/System.Collections/tests/Generic/CollectionExtensionsTests.cs @@ -45,14 +45,14 @@ namespace System.Collections.Tests public void TryAdd_NullIDictionary_ThrowsArgumentNullException() { IDictionary dictionary = null; - Assert.Throws("dictionary", () => dictionary.TryAdd("key", "value")); + AssertExtensions.Throws("dictionary", () => dictionary.TryAdd("key", "value")); } [Fact] public void TryAdd_NullKeyIDictionary_ThrowsArgumentNullException() { IDictionary dictionary = new SortedDictionary(); - Assert.Throws("key", () => dictionary.TryAdd(null, "value")); + AssertExtensions.Throws("key", () => dictionary.TryAdd(null, "value")); } [Fact] @@ -76,7 +76,7 @@ namespace System.Collections.Tests { IDictionary dictionary = null; string value = null; - Assert.Throws("dictionary", () => dictionary.Remove("key", out value)); + AssertExtensions.Throws("dictionary", () => dictionary.Remove("key", out value)); Assert.Null(value); } @@ -85,7 +85,7 @@ namespace System.Collections.Tests { IDictionary dictionary = new SortedDictionary(); string value = null; - Assert.Throws("key", () => dictionary.Remove(null, out value)); + AssertExtensions.Throws("key", () => dictionary.Remove(null, out value)); Assert.Null(value); } diff --git a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs index d231494e3d2..1fbf60054bf 100644 --- a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs +++ b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs @@ -73,8 +73,8 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullFilePath_ThrowsArgumentNullException() { - Assert.Throws("path", () => new Bitmap((string)null)); - Assert.Throws("path", () => new Bitmap((string)null, false)); + AssertExtensions.Throws("path", () => new Bitmap((string)null)); + AssertExtensions.Throws("path", () => new Bitmap((string)null, false)); } [ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -362,8 +362,8 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullImageWithSize_ThrowsArgumentNullException() { - Assert.Throws("image", () => new Bitmap(null, new Size(1, 2))); - Assert.Throws("image", () => new Bitmap(null, 1, 2)); + AssertExtensions.Throws("image", () => new Bitmap(null, new Size(1, 2))); + AssertExtensions.Throws("image", () => new Bitmap(null, 1, 2)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -599,7 +599,7 @@ namespace System.Drawing.Tests { using (var bitmap = new Bitmap(1, 1)) { - Assert.Throws("x", () => bitmap.GetPixel(x, 0)); + AssertExtensions.Throws("x", () => bitmap.GetPixel(x, 0)); } } @@ -610,7 +610,7 @@ namespace System.Drawing.Tests { using (var bitmap = new Bitmap(1, 1)) { - Assert.Throws("y", () => bitmap.GetPixel(0, y)); + AssertExtensions.Throws("y", () => bitmap.GetPixel(0, y)); } } @@ -971,7 +971,7 @@ namespace System.Drawing.Tests { using (var bitmap = new Bitmap(1, 1)) { - Assert.Throws("x", () => bitmap.SetPixel(x, 0, Color.Red)); + AssertExtensions.Throws("x", () => bitmap.SetPixel(x, 0, Color.Red)); } } @@ -982,7 +982,7 @@ namespace System.Drawing.Tests { using (var bitmap = new Bitmap(1, 1)) { - Assert.Throws("y", () => bitmap.SetPixel(0, y, Color.Red)); + AssertExtensions.Throws("y", () => bitmap.SetPixel(0, y, Color.Red)); } } diff --git a/src/libraries/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs b/src/libraries/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs index c2465789210..a4626b37dd0 100644 --- a/src/libraries/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs +++ b/src/libraries/System.Drawing.Common/tests/Drawing2D/LinearGradientBrushTests.cs @@ -239,8 +239,8 @@ namespace System.Drawing.Drawing2D.Tests [InlineData(LinearGradientMode.BackwardDiagonal + 1)] public void Ctor_InvalidLinearGradientMode_ThrowsEnumArgumentException(LinearGradientMode linearGradientMode) { - Assert.Throws("linearGradientMode", () => new LinearGradientBrush(new Rectangle(1, 2, 3, 4), Color.Empty, Color.Empty, linearGradientMode)); - Assert.Throws("linearGradientMode", () => new LinearGradientBrush(new RectangleF(1, 2, 3, 4), Color.Empty, Color.Empty, linearGradientMode)); + AssertExtensions.Throws("linearGradientMode", () => new LinearGradientBrush(new Rectangle(1, 2, 3, 4), Color.Empty, Color.Empty, linearGradientMode)); + AssertExtensions.Throws("linearGradientMode", () => new LinearGradientBrush(new RectangleF(1, 2, 3, 4), Color.Empty, Color.Empty, linearGradientMode)); } public static IEnumerable Ctor_HatchStyle_ForeColor_BackColor_TestData() @@ -656,7 +656,7 @@ namespace System.Drawing.Drawing2D.Tests public void WrapMode_SetInvalid_ThrowsInvalidEnumArgumentException(WrapMode wrapMode) { var brush = new LinearGradientBrush(new Rectangle(1, 2, 3, 4), Color.Plum, Color.Red, 45, true); - Assert.Throws("value", () => brush.WrapMode = wrapMode); + AssertExtensions.Throws("value", () => brush.WrapMode = wrapMode); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] diff --git a/src/libraries/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs b/src/libraries/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs index 719445b714a..75d01ca7081 100644 --- a/src/libraries/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs +++ b/src/libraries/System.Drawing.Common/tests/Drawing2D/MatrixTests.cs @@ -124,8 +124,8 @@ namespace System.Drawing.Drawing2D.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullPoints_ThrowsArgumentNullException() { - Assert.Throws("plgpts", () => new Matrix(new RectangleF(), null)); - Assert.Throws("plgpts", () => new Matrix(new Rectangle(), null)); + AssertExtensions.Throws("plgpts", () => new Matrix(new RectangleF(), null)); + AssertExtensions.Throws("plgpts", () => new Matrix(new Rectangle(), null)); } [ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -370,8 +370,8 @@ namespace System.Drawing.Drawing2D.Tests { using (var matrix = new Matrix()) { - Assert.Throws("matrix", () => matrix.Multiply(null)); - Assert.Throws("matrix", () => matrix.Multiply(null, MatrixOrder.Prepend)); + AssertExtensions.Throws("matrix", () => matrix.Multiply(null)); + AssertExtensions.Throws("matrix", () => matrix.Multiply(null, MatrixOrder.Prepend)); } } @@ -822,8 +822,8 @@ namespace System.Drawing.Drawing2D.Tests { using (var matrix = new Matrix()) { - Assert.Throws("pts", () => matrix.TransformPoints((Point[])null)); - Assert.Throws("pts", () => matrix.TransformPoints((PointF[])null)); + AssertExtensions.Throws("pts", () => matrix.TransformPoints((Point[])null)); + AssertExtensions.Throws("pts", () => matrix.TransformPoints((PointF[])null)); } } @@ -905,9 +905,9 @@ namespace System.Drawing.Drawing2D.Tests { using (var matrix = new Matrix()) { - Assert.Throws("pts", () => matrix.VectorTransformPoints(null)); - Assert.Throws("pts", () => matrix.TransformVectors((Point[])null)); - Assert.Throws("pts", () => matrix.TransformVectors((PointF[])null)); + AssertExtensions.Throws("pts", () => matrix.VectorTransformPoints(null)); + AssertExtensions.Throws("pts", () => matrix.TransformVectors((Point[])null)); + AssertExtensions.Throws("pts", () => matrix.TransformVectors((PointF[])null)); } } diff --git a/src/libraries/System.Drawing.Common/tests/GraphicsTests.cs b/src/libraries/System.Drawing.Common/tests/GraphicsTests.cs index 575f8c13f90..acfb9d61fa4 100644 --- a/src/libraries/System.Drawing.Common/tests/GraphicsTests.cs +++ b/src/libraries/System.Drawing.Common/tests/GraphicsTests.cs @@ -128,7 +128,7 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void FromHdc_ZeroHdc_ThrowsArgumentNullException() { - Assert.Throws("hdc", () => Graphics.FromHdc(IntPtr.Zero)); + AssertExtensions.Throws("hdc", () => Graphics.FromHdc(IntPtr.Zero)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -292,7 +292,7 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void FromImage_NullImage_ThrowsArgumentNullException() { - Assert.Throws("image", () => Graphics.FromImage(null)); + AssertExtensions.Throws("image", () => Graphics.FromImage(null)); } [ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] diff --git a/src/libraries/System.Drawing.Common/tests/IconTests.cs b/src/libraries/System.Drawing.Common/tests/IconTests.cs index 253ed70661d..269cde9acac 100644 --- a/src/libraries/System.Drawing.Common/tests/IconTests.cs +++ b/src/libraries/System.Drawing.Common/tests/IconTests.cs @@ -96,9 +96,9 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullFilePath_ThrowsArgumentNullException() { - Assert.Throws("path", () => new Icon((string)null)); - Assert.Throws("path", () => new Icon((string)null, new Size(32, 32))); - Assert.Throws("path", () => new Icon((string)null, 32, 32)); + AssertExtensions.Throws("path", () => new Icon((string)null)); + AssertExtensions.Throws("path", () => new Icon((string)null, new Size(32, 32))); + AssertExtensions.Throws("path", () => new Icon((string)null, 32, 32)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -455,7 +455,7 @@ namespace System.Drawing.Tests var icon = Icon.FromHandle(source.Handle); icon.Dispose(); - Assert.Throws("dataStream", () => icon.Save(null)); + AssertExtensions.Throws("dataStream", () => icon.Save(null)); } } diff --git a/src/libraries/System.Drawing.Common/tests/RegionTests.cs b/src/libraries/System.Drawing.Common/tests/RegionTests.cs index c6add75fa4f..5c23df5b739 100644 --- a/src/libraries/System.Drawing.Common/tests/RegionTests.cs +++ b/src/libraries/System.Drawing.Common/tests/RegionTests.cs @@ -126,7 +126,7 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullRegionData_ThrowsArgumentNullException() { - Assert.Throws("rgnData", () => new Region((RegionData)null)); + AssertExtensions.Throws("rgnData", () => new Region((RegionData)null)); } [ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -264,7 +264,7 @@ namespace System.Drawing.Tests [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] public void Ctor_NullGraphicsPath_ThrowsArgumentNullException() { - Assert.Throws("path", () => new Region((GraphicsPath)null)); + AssertExtensions.Throws("path", () => new Region((GraphicsPath)null)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -448,7 +448,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Complement((Region)null)); + AssertExtensions.Throws("region", () => region.Complement((Region)null)); } } @@ -575,7 +575,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("path", () => region.Complement((GraphicsPath)null)); + AssertExtensions.Throws("path", () => region.Complement((GraphicsPath)null)); } } @@ -667,7 +667,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Equals(null, s_graphic)); + AssertExtensions.Throws("region", () => region.Equals(null, s_graphic)); } } @@ -676,7 +676,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("g", () => region.Equals(region, null)); + AssertExtensions.Throws("g", () => region.Equals(region, null)); } } @@ -900,7 +900,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Exclude((Region)null)); + AssertExtensions.Throws("region", () => region.Exclude((Region)null)); } } @@ -1008,7 +1008,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("path", () => region.Exclude((GraphicsPath)null)); + AssertExtensions.Throws("path", () => region.Exclude((GraphicsPath)null)); } } @@ -1088,7 +1088,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("g", () => region.GetHrgn(null)); + AssertExtensions.Throws("g", () => region.GetHrgn(null)); } } @@ -1106,7 +1106,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("regionHandle", () => region.ReleaseHrgn(IntPtr.Zero)); + AssertExtensions.Throws("regionHandle", () => region.ReleaseHrgn(IntPtr.Zero)); } } @@ -1115,7 +1115,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("g", () => region.GetBounds(null)); + AssertExtensions.Throws("g", () => region.GetBounds(null)); } } @@ -1169,7 +1169,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("matrix", () => region.GetRegionScans(null)); + AssertExtensions.Throws("matrix", () => region.GetRegionScans(null)); } } @@ -1309,7 +1309,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Intersect((Region)null)); + AssertExtensions.Throws("region", () => region.Intersect((Region)null)); } } @@ -1445,7 +1445,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("path", () => region.Intersect((GraphicsPath)null)); + AssertExtensions.Throws("path", () => region.Intersect((GraphicsPath)null)); } } @@ -1470,7 +1470,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("g", () => region.IsEmpty(null)); + AssertExtensions.Throws("g", () => region.IsEmpty(null)); } } @@ -1488,7 +1488,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("g", () => region.IsInfinite(null)); + AssertExtensions.Throws("g", () => region.IsInfinite(null)); } } @@ -1958,7 +1958,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Union((Region)null)); + AssertExtensions.Throws("region", () => region.Union((Region)null)); } } @@ -2066,7 +2066,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("path", () => region.Union((GraphicsPath)null)); + AssertExtensions.Throws("path", () => region.Union((GraphicsPath)null)); } } @@ -2169,7 +2169,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("matrix", () => region.Transform(null)); + AssertExtensions.Throws("matrix", () => region.Transform(null)); } } @@ -2389,7 +2389,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("region", () => region.Xor((Region)null)); + AssertExtensions.Throws("region", () => region.Xor((Region)null)); } } @@ -2497,7 +2497,7 @@ namespace System.Drawing.Tests { using (var region = new Region()) { - Assert.Throws("path", () => region.Xor((GraphicsPath)null)); + AssertExtensions.Throws("path", () => region.Xor((GraphicsPath)null)); } } diff --git a/src/libraries/System.Drawing.Common/tests/StringFormatTests.cs b/src/libraries/System.Drawing.Common/tests/StringFormatTests.cs index 6de7b05608c..cf489c42fff 100644 --- a/src/libraries/System.Drawing.Common/tests/StringFormatTests.cs +++ b/src/libraries/System.Drawing.Common/tests/StringFormatTests.cs @@ -87,7 +87,7 @@ namespace System.Drawing.Tests [Fact] public void Ctor_NullFormat_ThrowsArgumentNullException() { - Assert.Throws("format", () => new StringFormat(null)); + AssertExtensions.Throws("format", () => new StringFormat(null)); } [ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))] @@ -283,7 +283,7 @@ namespace System.Drawing.Tests { using (var format = new StringFormat()) { - Assert.Throws("value", () => format.Alignment = alignment); + AssertExtensions.Throws("value", () => format.Alignment = alignment); } } @@ -356,7 +356,7 @@ namespace System.Drawing.Tests { using (var format = new StringFormat()) { - Assert.Throws("value", () => format.LineAlignment = alignment); + AssertExtensions.Throws("value", () => format.LineAlignment = alignment); } } @@ -389,7 +389,7 @@ namespace System.Drawing.Tests { using (var format = new StringFormat()) { - Assert.Throws("value", () => format.HotkeyPrefix = prefix); + AssertExtensions.Throws("value", () => format.HotkeyPrefix = prefix); } } @@ -420,7 +420,7 @@ namespace System.Drawing.Tests { using (var format = new StringFormat()) { - Assert.Throws("value", () => format.Trimming = trimming); + AssertExtensions.Throws("value", () => format.Trimming = trimming); } } diff --git a/src/libraries/System.IO.FileSystem.AccessControl/tests/DirectoryObjectSecurityTests.cs b/src/libraries/System.IO.FileSystem.AccessControl/tests/DirectoryObjectSecurityTests.cs index d013a00370a..a7ab176410a 100644 --- a/src/libraries/System.IO.FileSystem.AccessControl/tests/DirectoryObjectSecurityTests.cs +++ b/src/libraries/System.IO.FileSystem.AccessControl/tests/DirectoryObjectSecurityTests.cs @@ -29,7 +29,7 @@ namespace System.Security.AccessControl [Fact] public void ObjectInitialization_InvalidSecurityDescriptor() { - Assert.Throws("securityDescriptor", () => new CustomDirectoryObjectSecurity(null)); + AssertExtensions.Throws("securityDescriptor", () => new CustomDirectoryObjectSecurity(null)); } [Fact] @@ -87,76 +87,76 @@ namespace System.Security.AccessControl public void RemoveAuditRuleAll_InvalidObjectAuditRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAuditRuleAll(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAuditRuleAll(null)); } [Fact] public void RemoveAuditRuleSpecific_InvalidObjectAuditRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAuditRuleSpecific(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAuditRuleSpecific(null)); } [Fact] public void RemoveAuditRule_InvalidObjectAuditRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAuditRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAuditRule(null)); } [Fact] public void SetAuditRule_InvalidObjectAuditRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.SetAuditRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.SetAuditRule(null)); } [Fact] public void AddAuditRule_InvalidObjectAuditRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.AddAuditRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.AddAuditRule(null)); } [Fact] public void RemoveAccessRuleSpecific_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAccessRuleSpecific(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAccessRuleSpecific(null)); } [Fact] public void RemoveAccessRuleAll_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAccessRuleAll(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAccessRuleAll(null)); } [Fact] public void RemoveAccessRule_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.RemoveAccessRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.RemoveAccessRule(null)); } [Fact] public void ResetAccessRule_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.ResetAccessRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.ResetAccessRule(null)); } [Fact] public void SetAccessRule_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.SetAccessRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.SetAccessRule(null)); } [Fact] public void AddAccessRule_InvalidObjectAccessRule() { var customObjectSecurity = new CustomDirectoryObjectSecurity(); - Assert.Throws("rule", () => customObjectSecurity.AddAccessRule(null)); + AssertExtensions.Throws("rule", () => customObjectSecurity.AddAccessRule(null)); } private class CustomDirectoryObjectSecurity : DirectoryObjectSecurity diff --git a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAccessRuleTests.cs b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAccessRuleTests.cs index 1d73edb33ee..23d8adebcb3 100644 --- a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAccessRuleTests.cs +++ b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAccessRuleTests.cs @@ -26,7 +26,7 @@ namespace System.IO public void FileSystemAccessRule_InvalidFileSystemRights() { var identity = new SecurityIdentifier(WellKnownSidType.WorldSid, null); - Assert.Throws("fileSystemRights", () => + AssertExtensions.Throws("fileSystemRights", () => new FileSystemAccessRule(identity, (FileSystemRights)(-1), AccessControlType.Allow)); } diff --git a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAclExtensionsTests.cs b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAclExtensionsTests.cs index c3092911eb8..09f663147b5 100644 --- a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAclExtensionsTests.cs +++ b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAclExtensionsTests.cs @@ -171,7 +171,7 @@ namespace System.IO using (var file = new TempFile(Path.Combine(directory.Path, "file.txt"))) using (FileStream fileStream = File.Open(file.Path, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.None)) { - Assert.Throws("fileSecurity", () => FileSystemAclExtensions.SetAccessControl(fileStream, (FileSecurity)null)); + AssertExtensions.Throws("fileSecurity", () => FileSystemAclExtensions.SetAccessControl(fileStream, (FileSecurity)null)); } } diff --git a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAuditRuleTests.cs b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAuditRuleTests.cs index ec2fde1449a..00d87a88601 100644 --- a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAuditRuleTests.cs +++ b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemAuditRuleTests.cs @@ -42,7 +42,7 @@ namespace System.Security.AccessControl { var fileSystemRights = (FileSystemRights)(-1); var identity = new SecurityIdentifier(WellKnownSidType.WorldSid, null); - Assert.Throws("fileSystemRights", () => new FileSystemAuditRule(@"MYDOMAIN\MyAccount", fileSystemRights, AuditFlags.Failure)); + AssertExtensions.Throws("fileSystemRights", () => new FileSystemAuditRule(@"MYDOMAIN\MyAccount", fileSystemRights, AuditFlags.Failure)); } diff --git a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemSecurityTests.cs b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemSecurityTests.cs index 64666a52270..370162aa785 100644 --- a/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemSecurityTests.cs +++ b/src/libraries/System.IO.FileSystem.AccessControl/tests/FileSystemSecurityTests.cs @@ -18,7 +18,7 @@ namespace System.IO public void AddAccessRule_InvalidFileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.AddAccessRule(null)); + AssertExtensions.Throws("rule", () => fileSecurity.AddAccessRule(null)); } [Fact] @@ -41,7 +41,7 @@ namespace System.IO public void SetAccessRule_InvalidFileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.SetAccessRule(null)); + AssertExtensions.Throws("rule", () => fileSecurity.SetAccessRule(null)); } [Fact] @@ -89,7 +89,7 @@ namespace System.IO public void ResetAccessRule_InvalidFileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.ResetAccessRule(null)); + AssertExtensions.Throws("rule", () => fileSecurity.ResetAccessRule(null)); } [Fact] @@ -121,7 +121,7 @@ namespace System.IO public void RemoveAccessRule_InvalidFileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.RemoveAccessRule(null)); + AssertExtensions.Throws("rule", () => fileSecurity.RemoveAccessRule(null)); } [Fact] @@ -184,7 +184,7 @@ namespace System.IO public void RemoveAccessRuleSpecific_Invalid_FileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.RemoveAccessRuleSpecific(null)); + AssertExtensions.Throws("rule", () => fileSecurity.RemoveAccessRuleSpecific(null)); } [Fact] @@ -226,7 +226,7 @@ namespace System.IO public void RemoveAccessRuleAll_InvalidFileSystemAccessRule() { var fileSecurity = new FileSecurity(); - Assert.Throws("rule", () => fileSecurity.RemoveAccessRuleAll(null)); + AssertExtensions.Throws("rule", () => fileSecurity.RemoveAccessRuleAll(null)); } [Fact] diff --git a/src/libraries/System.Net.HttpListener/tests/HttpListenerPrefixCollectionTests.cs b/src/libraries/System.Net.HttpListener/tests/HttpListenerPrefixCollectionTests.cs index 9fc67fbdaed..69d64a92df7 100644 --- a/src/libraries/System.Net.HttpListener/tests/HttpListenerPrefixCollectionTests.cs +++ b/src/libraries/System.Net.HttpListener/tests/HttpListenerPrefixCollectionTests.cs @@ -453,7 +453,7 @@ namespace System.Net.Tests { var listener = new HttpListener(); string longPrefix = "http://" + new string('a', 256) + "/"; - Assert.Throws("hostName", () => listener.Prefixes.Add(longPrefix)); + AssertExtensions.Throws("hostName", () => listener.Prefixes.Add(longPrefix)); // Ouch: even though adding the prefix threw an exception, the prefix was still added. Assert.Equal(1, listener.Prefixes.Count); diff --git a/src/libraries/System.Net.HttpListener/tests/HttpListenerTests.cs b/src/libraries/System.Net.HttpListener/tests/HttpListenerTests.cs index 0ba5c43af48..a934443d356 100644 --- a/src/libraries/System.Net.HttpListener/tests/HttpListenerTests.cs +++ b/src/libraries/System.Net.HttpListener/tests/HttpListenerTests.cs @@ -129,7 +129,7 @@ namespace System.Net.Tests { using (var listener = new HttpListener()) { - Assert.Throws("asyncResult", () => listener.EndGetContext(null)); + AssertExtensions.Throws("asyncResult", () => listener.EndGetContext(null)); } } diff --git a/src/libraries/System.Net.HttpListener/tests/HttpListenerTimeoutManagerTests.cs b/src/libraries/System.Net.HttpListener/tests/HttpListenerTimeoutManagerTests.cs index 8e5f0714d9e..00dd5c23779 100644 --- a/src/libraries/System.Net.HttpListener/tests/HttpListenerTimeoutManagerTests.cs +++ b/src/libraries/System.Net.HttpListener/tests/HttpListenerTimeoutManagerTests.cs @@ -18,7 +18,7 @@ namespace System.Net.Tests { using (var listener = new HttpListener()) { - Assert.Throws("value", () => listener.TimeoutManager.MinSendBytesPerSecond = value); + AssertExtensions.Throws("value", () => listener.TimeoutManager.MinSendBytesPerSecond = value); } } @@ -31,11 +31,11 @@ namespace System.Net.Tests using (var listener = new HttpListener()) { TimeSpan timeSpan = TimeSpan.FromSeconds(totalSeconds); - Assert.Throws("value", () => listener.TimeoutManager.EntityBody = timeSpan); - Assert.Throws("value", () => listener.TimeoutManager.DrainEntityBody = timeSpan); - Assert.Throws("value", () => listener.TimeoutManager.RequestQueue = timeSpan); - Assert.Throws("value", () => listener.TimeoutManager.IdleConnection = timeSpan); - Assert.Throws("value", () => listener.TimeoutManager.HeaderWait = timeSpan); + AssertExtensions.Throws("value", () => listener.TimeoutManager.EntityBody = timeSpan); + AssertExtensions.Throws("value", () => listener.TimeoutManager.DrainEntityBody = timeSpan); + AssertExtensions.Throws("value", () => listener.TimeoutManager.RequestQueue = timeSpan); + AssertExtensions.Throws("value", () => listener.TimeoutManager.IdleConnection = timeSpan); + AssertExtensions.Throws("value", () => listener.TimeoutManager.HeaderWait = timeSpan); } } diff --git a/src/libraries/System.Runtime.WindowsRuntime/tests/System/IO/CreateSafeFileHandleTests.cs b/src/libraries/System.Runtime.WindowsRuntime/tests/System/IO/CreateSafeFileHandleTests.cs index d3afd09021f..6f54105e5f9 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/tests/System/IO/CreateSafeFileHandleTests.cs +++ b/src/libraries/System.Runtime.WindowsRuntime/tests/System/IO/CreateSafeFileHandleTests.cs @@ -15,28 +15,28 @@ namespace System.IO public void NullStorageFile_ThrowsArgumentNull() { IStorageFile file = null; - Assert.Throws("windowsRuntimeFile", () => file.CreateSafeFileHandle()); + AssertExtensions.Throws("windowsRuntimeFile", () => file.CreateSafeFileHandle()); } [Fact] public void FromStorageFile_BadAccessThrowsOutOfRange() { IStorageFile file = new StorageFileMock(); - Assert.Throws("access", () => file.CreateSafeFileHandle((FileAccess)100)); + AssertExtensions.Throws("access", () => file.CreateSafeFileHandle((FileAccess)100)); } [Fact] public void FromStorageFile_BadSharingThrowsOutOfRange() { IStorageFile file = new StorageFileMock(); - Assert.Throws("share", () => file.CreateSafeFileHandle(FileAccess.ReadWrite, (FileShare)100)); + AssertExtensions.Throws("share", () => file.CreateSafeFileHandle(FileAccess.ReadWrite, (FileShare)100)); } [Fact] public void FromStorageFile_BadOptionsThrowsOutOfRange() { IStorageFile file = new StorageFileMock(); - Assert.Throws("options", () => file.CreateSafeFileHandle(FileAccess.ReadWrite, FileShare.Read, (FileOptions)100)); + AssertExtensions.Throws("options", () => file.CreateSafeFileHandle(FileAccess.ReadWrite, FileShare.Read, (FileOptions)100)); } [Fact] @@ -65,42 +65,42 @@ namespace System.IO public void NullStorageFolder_ThrowsArgumentNull() { IStorageFolder folder = null; - Assert.Throws("rootDirectory", () => folder.CreateSafeFileHandle("foo", FileMode.OpenOrCreate)); + AssertExtensions.Throws("rootDirectory", () => folder.CreateSafeFileHandle("foo", FileMode.OpenOrCreate)); } [Fact] public void NullStorageFolder_ThrowsArgumentNull2() { IStorageFolder folder = null; - Assert.Throws("rootDirectory", () => folder.CreateSafeFileHandle("foo", FileMode.OpenOrCreate, FileAccess.Write)); + AssertExtensions.Throws("rootDirectory", () => folder.CreateSafeFileHandle("foo", FileMode.OpenOrCreate, FileAccess.Write)); } [Fact] public void FromStorageFolder_BadModeThrowsOutOfRange() { IStorageFolder folder = new StorageFolderMock(); - Assert.Throws("mode", () => folder.CreateSafeFileHandle("Foo", (FileMode)100)); + AssertExtensions.Throws("mode", () => folder.CreateSafeFileHandle("Foo", (FileMode)100)); } [Fact] public void FromStorageFolder_BadAccessThrowsOutOfRange() { IStorageFolder folder = new StorageFolderMock(); - Assert.Throws("access", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, (FileAccess)100)); + AssertExtensions.Throws("access", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, (FileAccess)100)); } [Fact] public void FromStorageFolder_BadSharingThrowsOutOfRange() { IStorageFolder folder = new StorageFolderMock(); - Assert.Throws("share", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, FileAccess.ReadWrite, (FileShare)100)); + AssertExtensions.Throws("share", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, FileAccess.ReadWrite, (FileShare)100)); } [Fact] public void FromStorageFolder_BadOptionsThrowsOutOfRange() { IStorageFolder folder = new StorageFolderMock(); - Assert.Throws("options", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, (FileOptions)100)); + AssertExtensions.Throws("options", () => folder.CreateSafeFileHandle("Foo", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read, (FileOptions)100)); } [Fact] diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs index ed2d48063b1..fdc43d93cf9 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/CryptoConfigTests.cs @@ -42,13 +42,13 @@ namespace System.Security.Cryptography.CryptoConfigTests [Fact] public static void AddOID_NullOid_Throws() { - Assert.Throws("oid", () => CryptoConfig.AddOID(null, string.Empty)); + AssertExtensions.Throws("oid", () => CryptoConfig.AddOID(null, string.Empty)); } [Fact] public static void AddOID_NullNames_Throws() { - Assert.Throws("names", () => CryptoConfig.AddOID(string.Empty, null)); + AssertExtensions.Throws("names", () => CryptoConfig.AddOID(string.Empty, null)); } [Fact] @@ -84,13 +84,13 @@ namespace System.Security.Cryptography.CryptoConfigTests [Fact] public static void AddAlgorithm_NullAlgorithm_Throws() { - Assert.Throws("algorithm", () => CryptoConfig.AddAlgorithm(null, string.Empty)); + AssertExtensions.Throws("algorithm", () => CryptoConfig.AddAlgorithm(null, string.Empty)); } [Fact] public static void AddAlgorithm_NullNames_Throws() { - Assert.Throws("names", () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), null)); + AssertExtensions.Throws("names", () => CryptoConfig.AddAlgorithm(typeof(CryptoConfigTests), null)); } [Fact] diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/CertificateRequestApiTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/CertificateRequestApiTests.cs index e6bd873bb97..988f14866d6 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/CertificateRequestApiTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/CertificateRequestApiTests.cs @@ -31,7 +31,7 @@ namespace System.Security.Cryptography.X509Certificates.Tests.CertificateCreatio { CertificateRequest request = new CertificateRequest("", ecdsa, HashAlgorithmName.SHA256); - Assert.Throws("signatureGenerator", () => request.CreateSigningRequest(null)); + AssertExtensions.Throws("signatureGenerator", () => request.CreateSigningRequest(null)); } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/SubjectAltNameBuilderTests.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/SubjectAltNameBuilderTests.cs index 48583eb546b..a5394c1927b 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/SubjectAltNameBuilderTests.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/CertificateCreation/SubjectAltNameBuilderTests.cs @@ -17,14 +17,14 @@ namespace System.Security.Cryptography.X509Certificates.Tests.CertificateCreatio { SubjectAlternativeNameBuilder builder = new SubjectAlternativeNameBuilder(); - Assert.Throws("dnsName", () => builder.AddDnsName(null)); - Assert.Throws("dnsName", () => builder.AddDnsName(string.Empty)); - Assert.Throws("emailAddress", () => builder.AddEmailAddress(null)); - Assert.Throws("emailAddress", () => builder.AddEmailAddress(string.Empty)); - Assert.Throws("uri", () => builder.AddUri(null)); - Assert.Throws("ipAddress", () => builder.AddIpAddress(null)); - Assert.Throws("upn", () => builder.AddUserPrincipalName(null)); - Assert.Throws("upn", () => builder.AddUserPrincipalName(string.Empty)); + AssertExtensions.Throws("dnsName", () => builder.AddDnsName(null)); + AssertExtensions.Throws("dnsName", () => builder.AddDnsName(string.Empty)); + AssertExtensions.Throws("emailAddress", () => builder.AddEmailAddress(null)); + AssertExtensions.Throws("emailAddress", () => builder.AddEmailAddress(string.Empty)); + AssertExtensions.Throws("uri", () => builder.AddUri(null)); + AssertExtensions.Throws("ipAddress", () => builder.AddIpAddress(null)); + AssertExtensions.Throws("upn", () => builder.AddUserPrincipalName(null)); + AssertExtensions.Throws("upn", () => builder.AddUserPrincipalName(string.Empty)); } [Fact] diff --git a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptionMethodTests.cs b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptionMethodTests.cs index 0e4db8c581f..c272f20e741 100644 --- a/src/libraries/System.Security.Cryptography.Xml/tests/EncryptionMethodTests.cs +++ b/src/libraries/System.Security.Cryptography.Xml/tests/EncryptionMethodTests.cs @@ -46,7 +46,7 @@ namespace System.Security.Cryptography.Xml.Tests { EncryptionMethod method = new EncryptionMethod(); if (PlatformDetection.IsFullFramework) - Assert.Throws("The key size should be a non negative integer.", () => method.KeySize = value); + AssertExtensions.Throws("The key size should be a non negative integer.", () => method.KeySize = value); else AssertExtensions.Throws("value", () => method.KeySize = value); }