From be159f37b9d2058d876119106c1292d374074c0b Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 19:47:09 +0100 Subject: [PATCH 01/12] Started updating the classic assert documentation --- .../assertions/assertion-models/classic.md | 64 ++-- .../assertion-models/classic_extensions.md | 281 ++++++++++++++++++ .../classic-assertions/Assert.AreEqual.md | 18 +- .../Snippets.NUnit/ClassicAssertExamples.cs | 193 ++++-------- .../ClassicCollectionAssertExamples.cs | 102 +++++++ .../ClassicVsConstraintAssertions.cs | 5 +- 6 files changed, 485 insertions(+), 178 deletions(-) create mode 100644 docs/articles/nunit/writing-tests/assertions/assertion-models/classic_extensions.md create mode 100644 docs/snippets/Snippets.NUnit/ClassicCollectionAssertExamples.cs diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md index 84ed893a2..992900fbe 100644 --- a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md @@ -12,32 +12,43 @@ Here's a simple assert using the classic model: StringAssert.AreEqualIgnoringCase("Hello", myString); ``` +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + +:NOTE: The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code +that already use this. + +:NOTE: The use of See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. + The Assert class provides the most common assertions in NUnit: -* [ClassicAssert.True](../classic-assertions/Assert.True.md) -* [ClassicAssert.False](../classic-assertions/Assert.False.md) -* [ClassicAssert.Null](../classic-assertions/Assert.Null.md) -* [ClassicAssert.NotNull](../classic-assertions/Assert.NotNull.md) -* [ClassicAssert.Zero](../classic-assertions/Assert.Zero.md) -* [ClassicAssert.NotZero](../classic-assertions/Assert.NotZero.md) -* [ClassicAssert.IsNaN](../classic-assertions/Assert.IsNaN.md) -* [ClassicAssert.IsEmpty](../classic-assertions/Assert.IsEmpty.md) -* [ClassicAssert.IsNotEmpty](../classic-assertions/Assert.IsNotEmpty.md) -* [ClassicAssert.AreEqual](../classic-assertions/Assert.AreEqual.md) -* [ClassicAssert.AreNotEqual](../classic-assertions/Assert.AreNotEqual.md) -* [ClassicAssert.AreSame](../classic-assertions/Assert.AreSame.md) -* [ClassicAssert.AreNotSame](../classic-assertions/Assert.AreNotSame.md) -* [ClassicAssert.Contains](../classic-assertions/Assert.Contains.md) -* [ClassicAssert.Greater](../classic-assertions/Assert.Greater.md) -* [ClassicAssert.GreaterOrEqual](../classic-assertions/Assert.GreaterOrEqual.md) -* [ClassicAssert.Less](../classic-assertions/Assert.Less.md) -* [ClassicAssert.LessOrEqual](../classic-assertions/Assert.LessOrEqual.md) -* [ClassicAssert.Positive](../classic-assertions/Assert.Positive.md) -* [ClassicAssert.Negative](../classic-assertions/Assert.Negative.md) -* [ClassicAssert.IsInstanceOf](../classic-assertions/Assert.IsInstanceOf.md) -* [ClassicAssert.IsNotInstanceOf](../classic-assertions/Assert.IsNotInstanceOf.md) -* [ClassicAssert.IsAssignableFrom](../classic-assertions/Assert.IsAssignableFrom.md) -* [ClassicAssert.IsNotAssignableFrom](../classic-assertions/Assert.IsNotAssignableFrom.md) +* [Assert.True](../classic-assertions/Assert.True.md) +* [Assert.False](../classic-assertions/Assert.False.md) +* [Assert.Null](../classic-assertions/Assert.Null.md) +* [Assert.NotNull](../classic-assertions/Assert.NotNull.md) +* [Assert.Zero](../classic-assertions/Assert.Zero.md) +* [Assert.NotZero](../classic-assertions/Assert.NotZero.md) +* [Assert.IsNaN](../classic-assertions/Assert.IsNaN.md) +* [Assert.IsEmpty](../classic-assertions/Assert.IsEmpty.md) +* [Assert.IsNotEmpty](../classic-assertions/Assert.IsNotEmpty.md) +* [Assert.AreEqual](../classic-assertions/Assert.AreEqual.md) +* [Assert.AreNotEqual](../classic-assertions/Assert.AreNotEqual.md) +* [Assert.AreSame](../classic-assertions/Assert.AreSame.md) +* [Assert.AreNotSame](../classic-assertions/Assert.AreNotSame.md) +* [Assert.Contains](../classic-assertions/Assert.Contains.md) +* [Assert.Greater](../classic-assertions/Assert.Greater.md) +* [Assert.GreaterOrEqual](../classic-assertions/Assert.GreaterOrEqual.md) +* [Assert.Less](../classic-assertions/Assert.Less.md) +* [Assert.LessOrEqual](../classic-assertions/Assert.LessOrEqual.md) +* [Assert.Positive](../classic-assertions/Assert.Positive.md) +* [Assert.Negative](../classic-assertions/Assert.Negative.md) +* [Assert.IsInstanceOf](../classic-assertions/Assert.IsInstanceOf.md) +* [Assert.IsNotInstanceOf](../classic-assertions/Assert.IsNotInstanceOf.md) +* [Assert.IsAssignableFrom](../classic-assertions/Assert.IsAssignableFrom.md) +* [Assert.IsNotAssignableFrom](../classic-assertions/Assert.IsNotAssignableFrom.md) * [Assert.Throws](../classic-assertions/Assert.Throws.md) * [Assert.ThrowsAsync](../classic-assertions/Assert.ThrowsAsync.md) * [Assert.DoesNotThrow](../classic-assertions/Assert.DoesNotThrow.md) @@ -45,7 +56,7 @@ The Assert class provides the most common assertions in NUnit: * [Assert.Catch](../classic-assertions/Assert.Catch.md) * [Assert.CatchAsync](../classic-assertions/Assert.CatchAsync.md) -Additional assertions are provided by the following classes, which are also in the `NUnit.Framework.Legacy` namespace: +Additional assertions are provided by the following classes, which are in the `NUnit.Framework.Legacy` namespace: * [String Assert](../classic-assertions/String-Assert.md) * [Collection Assert](../classic-assertions/Collection-Assert.md) @@ -58,5 +69,4 @@ Additional assertions are provided by the following classes, which are also in t ## Notes -* The exception-family of classic asserts have not yet been moved to the legacy namespace. They have not yet full - equivalents in the constraint model. +* The exception-family of classic asserts have not been moved to the legacy namespace. diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic_extensions.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic_extensions.md new file mode 100644 index 000000000..abb6b348a --- /dev/null +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic_extensions.md @@ -0,0 +1,281 @@ +# Classic Assert Extension Methods + +This document provides a comprehensive mapping of all ClassicAssert methods to their corresponding C#14 static extension methods on `Assert`. + +## Overview + +All extension methods provide 1:1 mapping with their corresponding ClassicAssert methods. Each ClassicAssert overload has exactly one matching extension method with identical signatures. + +--- + +## Core Assertions (ClassicExtensions.cs) + +### AreEqual + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.AreEqual(double, double, double)` | `Assert.AreEqual(double, double, double)` | +| `ClassicAssert.AreEqual(double, double, double, string, object[])` | `Assert.AreEqual(double, double, double, string, object[])` | +| `ClassicAssert.AreEqual(object, object)` | `Assert.AreEqual(object, object)` | +| `ClassicAssert.AreEqual(object, object, string, object[])` | `Assert.AreEqual(object, object, string, object[])` | + +### AreNotEqual + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.AreNotEqual(object, object)` | `Assert.AreNotEqual(object, object)` | +| `ClassicAssert.AreNotEqual(object, object, string, object[])` | `Assert.AreNotEqual(object, object, string, object[])` | + +### AreSame + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.AreSame(object, object)` | `Assert.AreSame(object, object)` | +| `ClassicAssert.AreSame(object, object, string, object[])` | `Assert.AreSame(object, object, string, object[])` | + +### AreNotSame + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.AreNotSame(object, object)` | `Assert.AreNotSame(object, object)` | +| `ClassicAssert.AreNotSame(object, object, string, object[])` | `Assert.AreNotSame(object, object, string, object[])` | + +### True / IsTrue + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.True(bool)` | `Assert.True(bool)` | +| `ClassicAssert.True(bool, string, object[])` | `Assert.True(bool, string, object[])` | +| `ClassicAssert.True(bool?)` | `Assert.True(bool?)` | +| `ClassicAssert.True(bool?, string, object[])` | `Assert.True(bool?, string, object[])` | +| `ClassicAssert.IsTrue(bool)` | `Assert.IsTrue(bool)` | +| `ClassicAssert.IsTrue(bool, string, object[])` | `Assert.IsTrue(bool, string, object[])` | +| `ClassicAssert.IsTrue(bool?)` | `Assert.IsTrue(bool?)` | +| `ClassicAssert.IsTrue(bool?, string, object[])` | `Assert.IsTrue(bool?, string, object[])` | + +### False / IsFalse + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.False(bool)` | `Assert.False(bool)` | +| `ClassicAssert.False(bool, string, object[])` | `Assert.False(bool, string, object[])` | +| `ClassicAssert.False(bool?)` | `Assert.False(bool?)` | +| `ClassicAssert.False(bool?, string, object[])` | `Assert.False(bool?, string, object[])` | +| `ClassicAssert.IsFalse(bool)` | `Assert.IsFalse(bool)` | +| `ClassicAssert.IsFalse(bool, string, object[])` | `Assert.IsFalse(bool, string, object[])` | +| `ClassicAssert.IsFalse(bool?)` | `Assert.IsFalse(bool?)` | +| `ClassicAssert.IsFalse(bool?, string, object[])` | `Assert.IsFalse(bool?, string, object[])` | + +### NotNull / IsNotNull + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.NotNull(object)` | `Assert.NotNull(object)` | +| `ClassicAssert.NotNull(object, string, object[])` | `Assert.NotNull(object, string, object[])` | +| `ClassicAssert.IsNotNull(object)` | `Assert.IsNotNull(object)` | +| `ClassicAssert.IsNotNull(object, string, object[])` | `Assert.IsNotNull(object, string, object[])` | + +### Null / IsNull + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Null(object)` | `Assert.Null(object)` | +| `ClassicAssert.Null(object, string, object[])` | `Assert.Null(object, string, object[])` | +| `ClassicAssert.IsNull(object)` | `Assert.IsNull(object)` | +| `ClassicAssert.IsNull(object, string, object[])` | `Assert.IsNull(object, string, object[])` | + +### IsNaN + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsNaN(double)` | `Assert.IsNaN(double)` | +| `ClassicAssert.IsNaN(double, string, object[])` | `Assert.IsNaN(double, string, object[])` | +| `ClassicAssert.IsNaN(double?)` | `Assert.IsNaN(double?)` | +| `ClassicAssert.IsNaN(double?, string, object[])` | `Assert.IsNaN(double?, string, object[])` | + +### IsEmpty + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsEmpty(string)` | `Assert.IsEmpty(string)` | +| `ClassicAssert.IsEmpty(string, string, object[])` | `Assert.IsEmpty(string, string, object[])` | +| `ClassicAssert.IsEmpty(IEnumerable)` | `Assert.IsEmpty(IEnumerable)` | +| `ClassicAssert.IsEmpty(IEnumerable, string, object[])` | `Assert.IsEmpty(IEnumerable, string, object[])` | + +### IsNotEmpty + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsNotEmpty(string)` | `Assert.IsNotEmpty(string)` | +| `ClassicAssert.IsNotEmpty(string, string, object[])` | `Assert.IsNotEmpty(string, string, object[])` | +| `ClassicAssert.IsNotEmpty(IEnumerable)` | `Assert.IsNotEmpty(IEnumerable)` | +| `ClassicAssert.IsNotEmpty(IEnumerable, string, object[])` | `Assert.IsNotEmpty(IEnumerable, string, object[])` | + +### Contains + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Contains(object, ICollection)` | `Assert.Contains(object, ICollection)` | +| `ClassicAssert.Contains(object, ICollection, string, object[])` | `Assert.Contains(object, ICollection, string, object[])` | + +--- + +## Numeric Assertions (ClassicExtensions.Numeric.cs) + +### Zero + +For each numeric type (int, uint, long, ulong, decimal, double, float): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Zero(T)` | `Assert.Zero(T)` | +| `ClassicAssert.Zero(T, string, object[])` | `Assert.Zero(T, string, object[])` | + +### NotZero + +For each numeric type (int, uint, long, ulong, decimal, double, float): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.NotZero(T)` | `Assert.NotZero(T)` | +| `ClassicAssert.NotZero(T, string, object[])` | `Assert.NotZero(T, string, object[])` | + +### Positive + +For each numeric type (int, uint, long, ulong, decimal, double, float): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Positive(T)` | `Assert.Positive(T)` | +| `ClassicAssert.Positive(T, string, object[])` | `Assert.Positive(T, string, object[])` | + +### Negative + +For each numeric type (int, uint, long, ulong, decimal, double, float): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Negative(T)` | `Assert.Negative(T)` | +| `ClassicAssert.Negative(T, string, object[])` | `Assert.Negative(T, string, object[])` | + +--- + +## Comparison Assertions (ClassicExtensions.Comparisons.cs) + +### Greater + +For each comparable type (int, uint, long, ulong, decimal, double, float, IComparable): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Greater(T, T)` | `Assert.Greater(T, T)` | +| `ClassicAssert.Greater(T, T, string, object[])` | `Assert.Greater(T, T, string, object[])` | + +### Less + +For each comparable type (int, uint, long, ulong, decimal, double, float, IComparable): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.Less(T, T)` | `Assert.Less(T, T)` | +| `ClassicAssert.Less(T, T, string, object[])` | `Assert.Less(T, T, string, object[])` | + +### GreaterOrEqual + +For each comparable type (int, uint, long, ulong, decimal, double, float, IComparable): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.GreaterOrEqual(T, T)` | `Assert.GreaterOrEqual(T, T)` | +| `ClassicAssert.GreaterOrEqual(T, T, string, object[])` | `Assert.GreaterOrEqual(T, T, string, object[])` | + +### LessOrEqual + +For each comparable type (int, uint, long, ulong, decimal, double, float, IComparable): + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.LessOrEqual(T, T)` | `Assert.LessOrEqual(T, T)` | +| `ClassicAssert.LessOrEqual(T, T, string, object[])` | `Assert.LessOrEqual(T, T, string, object[])` | + +--- + +## Type Assertions (ClassicExtensions.Types.cs) + +### IsAssignableFrom + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsAssignableFrom(Type, object)` | `Assert.IsAssignableFrom(Type, object)` | +| `ClassicAssert.IsAssignableFrom(Type, object, string, object[])` | `Assert.IsAssignableFrom(Type, object, string, object[])` | +| `ClassicAssert.IsAssignableFrom(object)` | `Assert.IsAssignableFrom(object)` | +| `ClassicAssert.IsAssignableFrom(object, string, object[])` | `Assert.IsAssignableFrom(object, string, object[])` | + +### IsNotAssignableFrom + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsNotAssignableFrom(Type, object)` | `Assert.IsNotAssignableFrom(Type, object)` | +| `ClassicAssert.IsNotAssignableFrom(Type, object, string, object[])` | `Assert.IsNotAssignableFrom(Type, object, string, object[])` | +| `ClassicAssert.IsNotAssignableFrom(object)` | `Assert.IsNotAssignableFrom(object)` | +| `ClassicAssert.IsNotAssignableFrom(object, string, object[])` | `Assert.IsNotAssignableFrom(object, string, object[])` | + +### IsInstanceOf + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsInstanceOf(Type, object)` | `Assert.IsInstanceOf(Type, object)` | +| `ClassicAssert.IsInstanceOf(Type, object, string, object[])` | `Assert.IsInstanceOf(Type, object, string, object[])` | +| `ClassicAssert.IsInstanceOf(object)` | `Assert.IsInstanceOf(object)` | +| `ClassicAssert.IsInstanceOf(object, string, object[])` | `Assert.IsInstanceOf(object, string, object[])` | + +### IsNotInstanceOf + +| ClassicAssert Method | Extension Method | +|---------------------|------------------| +| `ClassicAssert.IsNotInstanceOf(Type, object)` | `Assert.IsNotInstanceOf(Type, object)` | +| `ClassicAssert.IsNotInstanceOf(Type, object, string, object[])` | `Assert.IsNotInstanceOf(Type, object, string, object[])` | +| `ClassicAssert.IsNotInstanceOf(object)` | `Assert.IsNotInstanceOf(object)` | +| `ClassicAssert.IsNotInstanceOf(object, string, object[])` | `Assert.IsNotInstanceOf(object, string, object[])` | + +--- + +## Usage Notes + +### Requirements + +- **C# Version**: These extensions require C# 14 or later +- **Reference**: Require only `using NUnit.Framework;` to access extension methods + +### Documentation + +All extension methods use `/// ` to inherit their documentation from the corresponding ClassicAssert methods, ensuring consistency and maintainability. + +### Design Principles + +1. **1:1 Mapping**: Each ClassicAssert overload has exactly one corresponding extension method +2. **No Optional Parameters**: Separate overloads are used instead of optional parameters, as in the Classic Asserts. +3. **Type Safety**: Extension methods preserve all type constraints and signatures from the original methods +4. **Naming Conflicts**: Where method names would conflict (e.g., string Contains vs. collection Contains), prefixes are added for clarity + +### Migration Example + +**Before (Classic Assert):** + +```csharp +using NUnit.Framework.Legacy; + +ClassicAssert.AreEqual(expected, actual); +ClassicAssert.IsTrue(condition, "Custom message", arg1, arg2); +StringAssert.Contains("substring", str); +``` + +**After (Extension Methods):** + +```csharp +using NUnit.Framework; + +Assert.AreEqual(expected, actual); +Assert.IsTrue(condition, "Custom message", arg1, arg2); +Assert.StringContains("substring", str); +``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md index 84c9a1004..7f00c9638 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md @@ -1,14 +1,20 @@ -# ClassicAssert.AreEqual +# Assert.AreEqual -**ClassicAssert.AreEqual** tests whether the two arguments are equal. +**Assert.AreEqual** tests whether the two arguments are equal. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.AreEqual(double expected, double actual, double tolerance); -ClassicAssert.AreEqual(double expected, double actual, double tolerance, +Assert.AreEqual(double expected, double actual, double tolerance); +Assert.AreEqual(double expected, double actual, double tolerance, string message, params object[] params); -ClassicAssert.AreEqual(object expected, object actual); -ClassicAssert.AreEqual(object expected, object actual, +Assert.AreEqual(object expected, object actual); +Assert.AreEqual(object expected, object actual, string message, params object[] params); ``` diff --git a/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs b/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs index eb639f4f9..fdecdde24 100644 --- a/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs +++ b/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using NUnit.Framework.Legacy; #pragma warning disable CA1822 #pragma warning disable NUnit2045 @@ -48,9 +47,9 @@ public void AreNotEqual_Examples() [Test] public void True_Examples() { - ClassicAssert.True(2 + 2 == 4); - ClassicAssert.IsTrue(true); - ClassicAssert.True("Hello".StartsWith("H")); + Assert.True(2 + 2 == 4); + Assert.IsTrue(true); + Assert.True("Hello".StartsWith("H")); } #endregion @@ -73,12 +72,12 @@ public void False_Examples() public void Null_Examples() { object obj = null; - ClassicAssert.Null(obj); - ClassicAssert.IsNull(obj); + Assert.Null(obj); + Assert.IsNull(obj); obj = "something"; - ClassicAssert.NotNull(obj); - ClassicAssert.IsNotNull(obj); + Assert.NotNull(obj); + Assert.IsNotNull(obj); } #endregion #pragma warning restore CS8600 @@ -92,8 +91,8 @@ public void Same_Examples() object obj2 = obj1; object obj3 = new object(); - ClassicAssert.AreSame(obj1, obj2); - ClassicAssert.AreNotSame(obj1, obj3); + Assert.AreSame(obj1, obj2); + Assert.AreNotSame(obj1, obj3); } #endregion @@ -101,10 +100,10 @@ public void Same_Examples() [Test] public void Greater_Examples() { - ClassicAssert.Greater(7, 3); - ClassicAssert.Greater(3.5, 2.1); - ClassicAssert.Greater("b", "a"); - ClassicAssert.Greater(DateTime.Now, DateTime.Now.AddDays(-1)); + Assert.Greater(7, 3); + Assert.Greater(3.5, 2.1); + Assert.Greater("b", "a"); + Assert.Greater(DateTime.Now, DateTime.Now.AddDays(-1)); } #endregion @@ -112,10 +111,10 @@ public void Greater_Examples() [Test] public void GreaterOrEqual_Examples() { - ClassicAssert.GreaterOrEqual(7, 3); - ClassicAssert.GreaterOrEqual(7, 7); - ClassicAssert.GreaterOrEqual("b", "a"); - ClassicAssert.GreaterOrEqual("b", "b"); + Assert.GreaterOrEqual(7, 3); + Assert.GreaterOrEqual(7, 7); + Assert.GreaterOrEqual("b", "a"); + Assert.GreaterOrEqual("b", "b"); } #endregion @@ -123,9 +122,9 @@ public void GreaterOrEqual_Examples() [Test] public void Less_Examples() { - ClassicAssert.Less(3, 7); - ClassicAssert.Less(2.1, 3.5); - ClassicAssert.Less("a", "b"); + Assert.Less(3, 7); + Assert.Less(2.1, 3.5); + Assert.Less("a", "b"); } #endregion @@ -133,10 +132,10 @@ public void Less_Examples() [Test] public void LessOrEqual_Examples() { - ClassicAssert.LessOrEqual(3, 7); - ClassicAssert.LessOrEqual(7, 7); - ClassicAssert.LessOrEqual("a", "b"); - ClassicAssert.LessOrEqual("a", "a"); + Assert.LessOrEqual(3, 7); + Assert.LessOrEqual(7, 7); + Assert.LessOrEqual("a", "b"); + Assert.LessOrEqual("a", "a"); } #endregion @@ -145,10 +144,10 @@ public void LessOrEqual_Examples() public void Contains_Examples() { var list = new List { 1, 2, 3, 4, 5 }; - ClassicAssert.Contains(3, list); + Assert.Contains(3, list); var array = new string[] { "apple", "banana", "cherry" }; - ClassicAssert.Contains("banana", array); + Assert.Contains("banana", array); } #endregion @@ -156,17 +155,17 @@ public void Contains_Examples() [Test] public void PositiveNegativeZero_Examples() { - ClassicAssert.Positive(5); - ClassicAssert.Positive(0.1); + Assert.Positive(5); + Assert.Positive(0.1); - ClassicAssert.Negative(-5); - ClassicAssert.Negative(-0.1); + Assert.Negative(-5); + Assert.Negative(-0.1); - ClassicAssert.Zero(0); - ClassicAssert.Zero(0.0); + Assert.Zero(0); + Assert.Zero(0.0); - ClassicAssert.NotZero(5); - ClassicAssert.NotZero(-3); + Assert.NotZero(5); + Assert.NotZero(-3); } #endregion @@ -174,8 +173,8 @@ public void PositiveNegativeZero_Examples() [Test] public void NaN_Examples() { - ClassicAssert.IsNaN(double.NaN); - ClassicAssert.IsNaN(float.NaN); + Assert.IsNaN(double.NaN); + Assert.IsNaN(float.NaN); } #endregion @@ -183,13 +182,13 @@ public void NaN_Examples() [Test] public void Empty_Examples() { - ClassicAssert.IsEmpty(""); - ClassicAssert.IsEmpty(new int[] { }); - ClassicAssert.IsEmpty(new List()); + Assert.IsEmpty(""); + Assert.IsEmpty(new int[] { }); + Assert.IsEmpty(new List()); - ClassicAssert.IsNotEmpty("Hello"); - ClassicAssert.IsNotEmpty(new int[] { 1, 2, 3 }); - ClassicAssert.IsNotEmpty(new List { "item" }); + Assert.IsNotEmpty("Hello"); + Assert.IsNotEmpty(new int[] { 1, 2, 3 }); + Assert.IsNotEmpty(new List { "item" }); } #endregion @@ -197,12 +196,12 @@ public void Empty_Examples() [Test] public void InstanceOf_Examples() { - ClassicAssert.IsInstanceOf("Hello"); - ClassicAssert.IsInstanceOf(typeof(string), "Hello"); - ClassicAssert.IsInstanceOf("Hello"); + Assert.IsInstanceOf("Hello"); + Assert.IsInstanceOf(typeof(string), "Hello"); + Assert.IsInstanceOf("Hello"); - ClassicAssert.IsNotInstanceOf("Hello"); - ClassicAssert.IsNotInstanceOf(typeof(int), "Hello"); + Assert.IsNotInstanceOf("Hello"); + Assert.IsNotInstanceOf(typeof(int), "Hello"); } #endregion @@ -212,101 +211,11 @@ public void AssignableFrom_Examples() { // object can be assigned FROM string (string is a subtype of object) object obj = "Hello"; - ClassicAssert.IsAssignableFrom(obj); - ClassicAssert.IsAssignableFrom(typeof(string), obj); + Assert.IsAssignableFrom(obj); + Assert.IsAssignableFrom(typeof(string), obj); - ClassicAssert.IsNotAssignableFrom("Hello"); - ClassicAssert.IsNotAssignableFrom(typeof(int), "Hello"); + Assert.IsNotAssignableFrom("Hello"); + Assert.IsNotAssignableFrom(typeof(int), "Hello"); } #endregion -} - -public class CollectionAssertExamples -{ - #region CollectionAssertBasicExamples - [Test] - public void CollectionAssert_Basic_Examples() - { - var list1 = new int[] { 1, 2, 3 }; - var list2 = new int[] { 1, 2, 3 }; - var list3 = new int[] { 3, 2, 1 }; - var list4 = new int[] { 1, 2, 4 }; - - // Collections are equal (same order) - CollectionAssert.AreEqual(list1, list2); - - // Collections are equivalent (same items, any order) - CollectionAssert.AreEquivalent(list1, list3); - - // Collections are not equal - CollectionAssert.AreNotEqual(list1, list4); - - // Collections are not equivalent - CollectionAssert.AreNotEquivalent(list1, list4); - } - #endregion - - #region CollectionAssertContainsExamples - [Test] - public void CollectionAssert_Contains_Examples() - { - var list = new int[] { 1, 2, 3, 4, 5 }; - - CollectionAssert.Contains(list, 3); - CollectionAssert.DoesNotContain(list, 10); - } - #endregion - - #region CollectionAssertSubsetExamples - [Test] - public void CollectionAssert_Subset_Examples() - { - var superset = new int[] { 1, 2, 3, 4, 5 }; - var subset = new int[] { 2, 4 }; - var notSubset = new int[] { 1, 6 }; - - CollectionAssert.IsSubsetOf(subset, superset); - CollectionAssert.IsNotSubsetOf(notSubset, superset); - } - #endregion - - #region CollectionAssertEmptyExamples - [Test] - public void CollectionAssert_Empty_Examples() - { - var emptyList = new int[] { }; - var nonEmptyList = new int[] { 1, 2, 3 }; - - CollectionAssert.IsEmpty(emptyList); - CollectionAssert.IsNotEmpty(nonEmptyList); - } - #endregion - - #region CollectionAssertOrderedExamples - [Test] - public void CollectionAssert_Ordered_Examples() - { - var orderedList = new int[] { 1, 2, 3, 4, 5 }; - var reverseOrderedList = new int[] { 5, 4, 3, 2, 1 }; - - CollectionAssert.IsOrdered(orderedList); - CollectionAssert.IsOrdered(reverseOrderedList, Comparer.Create((x, y) => y.CompareTo(x))); - } - #endregion - - -#pragma warning disable CS8625 - #region CollectionAssertItemTypeExamples - [Test] - public void CollectionAssert_ItemType_Examples() - { - var stringList = new string[] { "a", "b", "c" }; - var mixedList = new object[] { "string", 123, null }; - - CollectionAssert.AllItemsAreInstancesOfType(stringList, typeof(string)); - CollectionAssert.AllItemsAreNotNull(stringList); - CollectionAssert.AllItemsAreUnique(stringList); - } - #endregion -#pragma warning restore CS8625 } \ No newline at end of file diff --git a/docs/snippets/Snippets.NUnit/ClassicCollectionAssertExamples.cs b/docs/snippets/Snippets.NUnit/ClassicCollectionAssertExamples.cs new file mode 100644 index 000000000..695bd7274 --- /dev/null +++ b/docs/snippets/Snippets.NUnit/ClassicCollectionAssertExamples.cs @@ -0,0 +1,102 @@ +using NUnit.Framework; +using NUnit.Framework.Legacy; + +#pragma warning disable CA1822 +#pragma warning disable NUnit2045 +#pragma warning disable NUnit2005 +#pragma warning disable NUnit2006 +#pragma warning disable NUnit2015 +#pragma warning disable NUnit2031 +#pragma warning disable NUnit2049 + +namespace Snippets.NUnit; + +public class CollectionAssertExamples +{ + #region CollectionAssertBasicExamples + [Test] + public void CollectionAssert_Basic_Examples() + { + var list1 = new[] { 1, 2, 3 }; + var list2 = new[] { 1, 2, 3 }; + var list3 = new[] { 3, 2, 1 }; + var list4 = new[] { 1, 2, 4 }; + + // Collections are equal (same order) + CollectionAssert.AreEqual(list1, list2); + + // Collections are equivalent (same items, any order) + CollectionAssert.AreEquivalent(list1, list3); + + // Collections are not equal + CollectionAssert.AreNotEqual(list1, list4); + + // Collections are not equivalent + CollectionAssert.AreNotEquivalent(list1, list4); + } + #endregion + + #region CollectionAssertContainsExamples + [Test] + public void CollectionAssert_Contains_Examples() + { + var list = new[] { 1, 2, 3, 4, 5 }; + + CollectionAssert.Contains(list, 3); + CollectionAssert.DoesNotContain(list, 10); + } + #endregion + + #region CollectionAssertSubsetExamples + [Test] + public void CollectionAssert_Subset_Examples() + { + var superset = new[] { 1, 2, 3, 4, 5 }; + var subset = new[] { 2, 4 }; + var notSubset = new[] { 1, 6 }; + + CollectionAssert.IsSubsetOf(subset, superset); + CollectionAssert.IsNotSubsetOf(notSubset, superset); + } + #endregion + + #region CollectionAssertEmptyExamples + [Test] + public void CollectionAssert_Empty_Examples() + { + var emptyList = new int[] { }; + var nonEmptyList = new[] { 1, 2, 3 }; + + CollectionAssert.IsEmpty(emptyList); + CollectionAssert.IsNotEmpty(nonEmptyList); + } + #endregion + + #region CollectionAssertOrderedExamples + [Test] + public void CollectionAssert_Ordered_Examples() + { + var orderedList = new[] { 1, 2, 3, 4, 5 }; + var reverseOrderedList = new[] { 5, 4, 3, 2, 1 }; + + CollectionAssert.IsOrdered(orderedList); + CollectionAssert.IsOrdered(reverseOrderedList, Comparer.Create((x, y) => y.CompareTo(x))); + } + #endregion + + +#pragma warning disable CS8625 + #region CollectionAssertItemTypeExamples + [Test] + public void CollectionAssert_ItemType_Examples() + { + var stringList = new[] { "a", "b", "c" }; + var mixedList = new object[] { "string", 123, null }; + + CollectionAssert.AllItemsAreInstancesOfType(stringList, typeof(string)); + CollectionAssert.AllItemsAreNotNull(stringList); + CollectionAssert.AllItemsAreUnique(stringList); + } + #endregion +#pragma warning restore CS8625 +} \ No newline at end of file diff --git a/docs/snippets/Snippets.NUnit/ClassicVsConstraintAssertions.cs b/docs/snippets/Snippets.NUnit/ClassicVsConstraintAssertions.cs index f4e996426..f78860d76 100644 --- a/docs/snippets/Snippets.NUnit/ClassicVsConstraintAssertions.cs +++ b/docs/snippets/Snippets.NUnit/ClassicVsConstraintAssertions.cs @@ -3,7 +3,6 @@ #pragma warning disable NUnit2007 #pragma warning disable NUnit2005 -using NUnit.Framework.Legacy; namespace Snippets.NUnit; @@ -13,14 +12,14 @@ public class ClassicVsConstraintAssertions public void TheTest() { #region ConstraintWithoutClassicEquivalent - int[] array = { 1, 2, 3 }; + int[] array = [1, 2, 3]; Assert.That(array, Has.Exactly(1).EqualTo(3)); Assert.That(array, Has.Exactly(2).GreaterThan(1)); Assert.That(array, Has.Exactly(3).LessThan(100)); #endregion #region ClassicAndConstraintsAreEquivalent - ClassicAssert.AreEqual(4, 2 + 2); + Assert.AreEqual(4, 2 + 2); Assert.That(2 + 2, Is.EqualTo(4)); #endregion } From dd308a527ca77b8be1cca1069174a23b1b515d65 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 20:29:41 +0100 Subject: [PATCH 02/12] Updated documentation for classic asserts --- .../classic-assertions/Assert.AreEqual.md | 2 +- .../classic-assertions/Assert.AreNotEqual.md | 18 ++++--- .../classic-assertions/Assert.AreNotSame.md | 14 ++++-- .../classic-assertions/Assert.AreSame.md | 14 ++++-- .../classic-assertions/Assert.Contains.md | 14 ++++-- .../classic-assertions/Assert.False.md | 18 ++++--- .../classic-assertions/Assert.Greater.md | 50 +++++++++++-------- .../Assert.GreaterOrEqual.md | 50 +++++++++++-------- .../Assert.IsAssignableFrom.md | 18 ++++--- .../classic-assertions/Assert.IsEmpty.md | 20 +++++--- .../classic-assertions/Assert.IsInstanceOf.md | 18 ++++--- .../classic-assertions/Assert.IsNaN.md | 14 ++++-- .../Assert.IsNotAssignableFrom.md | 18 ++++--- .../classic-assertions/Assert.IsNotEmpty.md | 20 +++++--- .../Assert.IsNotInstanceOf.md | 18 ++++--- .../classic-assertions/Assert.Less.md | 50 +++++++++++-------- .../classic-assertions/Assert.LessOrEqual.md | 50 +++++++++++-------- .../classic-assertions/Assert.Negative.md | 50 +++++++++++-------- .../classic-assertions/Assert.NotNull.md | 18 ++++--- .../classic-assertions/Assert.NotZero.md | 40 ++++++++------- .../classic-assertions/Assert.Null.md | 18 ++++--- .../classic-assertions/Assert.Positive.md | 50 +++++++++++-------- .../classic-assertions/Assert.True.md | 18 ++++--- .../classic-assertions/Assert.Zero.md | 38 ++++++++------ .../Snippets.NUnit/ClassicAssertExamples.cs | 26 +++++----- 25 files changed, 401 insertions(+), 263 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md index 7f00c9638..7a649dd0a 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md @@ -5,7 +5,7 @@ :NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier version, replace Assert with ClassicAssert and include the +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the NUnit.Framework.Legacy namespace. ```csharp diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md index b30c0ae4b..2e7f1f7f2 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md @@ -1,16 +1,22 @@ -# ClassicAssert.AreNotEqual +# Assert.AreNotEqual -**ClassicAssert.AreNotEqual** tests whether the two arguments are unequal. +**Assert.AreNotEqual** tests whether the two arguments are unequal. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.AreNotEqual(object expected, object actual); -ClassicAssert.AreNotEqual(object expected, object actual, +Assert.AreNotEqual(object expected, object actual); +Assert.AreNotEqual(object expected, object actual, string message, params object[] params); ``` -See [ClassicAssert.AreEqual](Assert.AreEqual.md) for details of how NUnit performs equality comparisons. +See [Assert.AreEqual](Assert.AreEqual.md) for details of how NUnit performs equality comparisons. ## See Also -* [ClassicAssert.AreEqual](Assert.AreEqual.md) +* [Assert.AreEqual](Assert.AreEqual.md) * [Equal Constraint](xref:equalconstraint) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md index c5dd8bab7..72301ce78 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md @@ -1,10 +1,16 @@ -# ClassicAssert.AreNotSame +# Assert.AreNotSame -**ClassicAssert.AreNotSame** tests that the two arguments do not reference the same object. +**Assert.AreNotSame** tests that the two arguments do not reference the same object. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.AreNotSame(object expected, object actual); -ClassicAssert.AreNotSame(object expected, object actual, +Assert.AreNotSame(object expected, object actual); +Assert.AreNotSame(object expected, object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md index 165bce5e0..a9478d962 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md @@ -1,10 +1,16 @@ -# ClassicAssert.AreSame +# Assert.AreSame -**ClassicAssert.AreSame** tests that the two arguments reference the same object. +**Assert.AreSame** tests that the two arguments reference the same object. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.AreSame(object expected, object actual); -ClassicAssert.AreSame(object expected, object actual, +Assert.AreSame(object expected, object actual); +Assert.AreSame(object expected, object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md index 9d4e5b952..435669b77 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md @@ -1,11 +1,17 @@ -# ClassicAssert.Contains +# Assert.Contains -**ClassicAssert.Contains** is used to test whether an object is contained in a +**Assert.Contains** is used to test whether an object is contained in a collection. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.Contains(object anObject, ICollection collection); -ClassicAssert.Contains(object anObject, ICollection collection, +Assert.Contains(object anObject, ICollection collection); +Assert.Contains(object anObject, ICollection collection, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md index 318ad5cdc..036194b42 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md @@ -1,15 +1,21 @@ -# ClassicAssert.False +# Assert.False -**ClassicAssert.False** and **ClassicAssert.IsFalse** test that the specified condition is false. +**Assert.False** and **Assert.IsFalse** test that the specified condition is false. The two forms are provided for compatibility with past versions of NUnit and NUnitLite. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.False(bool condition); -ClassicAssert.False(bool condition, string message, params object[] params); +Assert.False(bool condition); +Assert.False(bool condition, string message, params object[] params); -ClassicAssert.IsFalse(bool condition); -ClassicAssert.IsFalse(bool condition, string message, params object[] params); +Assert.IsFalse(bool condition); +Assert.IsFalse(bool condition, string message, params object[] params); ``` ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md index 003c85c8b..0d0ac8791 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md @@ -1,47 +1,53 @@ -# ClassicAssert.Greater +# Assert.Greater -**ClassicAssert.Greater** tests whether one object is greater than another. +**Assert.Greater** tests whether one object is greater than another. Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus -**ClassicAssert.Greater(x, y)** asserts that x is greater than y (x > y). +**Assert.Greater(x, y)** asserts that x is greater than y (x > y). + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.Greater(int arg1, int arg2); -ClassicAssert.Greater(int arg1, int arg2, +Assert.Greater(int arg1, int arg2); +Assert.Greater(int arg1, int arg2, string message, params object[] params); -ClassicAssert.Greater(uint arg1, uint arg2); -ClassicAssert.Greater(uint arg1, uint arg2, +Assert.Greater(uint arg1, uint arg2); +Assert.Greater(uint arg1, uint arg2, string message, params object[] params); -ClassicAssert.Greater(long arg1, long arg2); -ClassicAssert.Greater(long arg1, long arg2, +Assert.Greater(long arg1, long arg2); +Assert.Greater(long arg1, long arg2, string message, params object[] params); -ClassicAssert.Greater(ulong arg1, ulong arg2); -ClassicAssert.Greater(ulong arg1, ulong arg2, +Assert.Greater(ulong arg1, ulong arg2); +Assert.Greater(ulong arg1, ulong arg2, string message, params object[] params); -ClassicAssert.Greater(decimal arg1, decimal arg2); -ClassicAssert.Greater(decimal arg1, decimal arg2, +Assert.Greater(decimal arg1, decimal arg2); +Assert.Greater(decimal arg1, decimal arg2, string message, params object[] params); -ClassicAssert.Greater(double arg1, double arg2); -ClassicAssert.Greater(double arg1, double arg2, +Assert.Greater(double arg1, double arg2); +Assert.Greater(double arg1, double arg2, string message, params object[] params); -ClassicAssert.Greater(float arg1, float arg2); -ClassicAssert.Greater(float arg1, float arg2, +Assert.Greater(float arg1, float arg2); +Assert.Greater(float arg1, float arg2, string message, params object[] params); -ClassicAssert.Greater(IComparable arg1, IComparable arg2); -ClassicAssert.Greater(IComparable arg1, IComparable arg2, +Assert.Greater(IComparable arg1, IComparable arg2); +Assert.Greater(IComparable arg1, IComparable arg2, string message, params object[] params); ``` ## See Also -* [ClassicAssert.GreaterOrEqual](Assert.GreaterOrEqual.md) -* [ClassicAssert.Less](Assert.Less.md) -* [ClassicAssert.LessOrEqual](Assert.LessOrEqual.md) +* [Assert.GreaterOrEqual](Assert.GreaterOrEqual.md) +* [Assert.Less](Assert.Less.md) +* [Assert.LessOrEqual](Assert.LessOrEqual.md) * [Comparison Constraints](xref:constraints#comparison-constraints) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md index e42a12447..7bcb34984 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md @@ -1,47 +1,53 @@ -# ClassicAssert.GreaterOrEqual +# Assert.GreaterOrEqual -**ClassicAssert.GreaterOrEqual** tests whether one object is greater than or equal to another. +**Assert.GreaterOrEqual** tests whether one object is greater than or equal to another. Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus -**ClassicAssert.GreaterOrEqual(x, y)** asserts that x is greater than or equal to y (x >= y). +**Assert.GreaterOrEqual(x, y)** asserts that x is greater than or equal to y (x >= y). + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.GreaterOrEqual(int arg1, int arg2); -ClassicAssert.GreaterOrEqual(int arg1, int arg2, +Assert.GreaterOrEqual(int arg1, int arg2); +Assert.GreaterOrEqual(int arg1, int arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(uint arg1, uint arg2); -ClassicAssert.GreaterOrEqual(uint arg1, uint arg2, +Assert.GreaterOrEqual(uint arg1, uint arg2); +Assert.GreaterOrEqual(uint arg1, uint arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(long arg1, long arg2); -ClassicAssert.GreaterOrEqual(long arg1, long arg2, +Assert.GreaterOrEqual(long arg1, long arg2); +Assert.GreaterOrEqual(long arg1, long arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(ulong arg1, ulong arg2); -ClassicAssert.GreaterOrEqual(ulong arg1, ulong arg2, +Assert.GreaterOrEqual(ulong arg1, ulong arg2); +Assert.GreaterOrEqual(ulong arg1, ulong arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(decimal arg1, decimal arg2); -ClassicAssert.GreaterOrEqual(decimal arg1, decimal arg2, +Assert.GreaterOrEqual(decimal arg1, decimal arg2); +Assert.GreaterOrEqual(decimal arg1, decimal arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(double arg1, double arg2); -ClassicAssert.GreaterOrEqual(double arg1, double arg2, +Assert.GreaterOrEqual(double arg1, double arg2); +Assert.GreaterOrEqual(double arg1, double arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(float arg1, float arg2); -ClassicAssert.GreaterOrEqual(float arg1, float arg2, +Assert.GreaterOrEqual(float arg1, float arg2); +Assert.GreaterOrEqual(float arg1, float arg2, string message, params object[] params); -ClassicAssert.GreaterOrEqual(IComparable arg1, IComparable arg2); -ClassicAssert.GreaterOrEqual(IComparable arg1, IComparable arg2, +Assert.GreaterOrEqual(IComparable arg1, IComparable arg2); +Assert.GreaterOrEqual(IComparable arg1, IComparable arg2, string message, params object[] params); ``` ## See Also -* [ClassicAssert.Greater](Assert.Greater.md) -* [ClassicAssert.Less](Assert.Less.md) -* [ClassicAssert.LessOrEqual](Assert.LessOrEqual.md) +* [Assert.Greater](Assert.Greater.md) +* [Assert.Less](Assert.Less.md) +* [Assert.LessOrEqual](Assert.LessOrEqual.md) * [Comparison Constraints](xref:constraints#comparison-constraints) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md index f26ea617e..a21b9e473 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md @@ -1,13 +1,19 @@ -# ClassicAssert.IsAssignableFrom +# Assert.IsAssignableFrom -**ClassicAssert.IsAssignableFrom** succeeds if the object provided may be assigned a value of the expected type. +**Assert.IsAssignableFrom** succeeds if the object provided may be assigned a value of the expected type. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.IsAssignableFrom(Type expected, object actual); -ClassicAssert.IsAssignableFrom(Type expected, object actual, +Assert.IsAssignableFrom(Type expected, object actual); +Assert.IsAssignableFrom(Type expected, object actual, string message, params object[] params); -ClassicAssert.IsAssignableFrom(object actual); -ClassicAssert.IsAssignableFrom(object actual, +Assert.IsAssignableFrom(object actual); +Assert.IsAssignableFrom(object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md index a9347834c..e970a2272 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md @@ -1,19 +1,25 @@ -# ClassicAssert.IsEmpty +# Assert.IsEmpty -**ClassicAssert.IsEmpty** may be used to test either a string or a collection or IEnumerable. When used with a string, +**Assert.IsEmpty** may be used to test either a string or a collection or IEnumerable. When used with a string, it succeeds if the string is the empty string. When used with a collection, it succeeds if the collection is empty. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.IsEmpty(string aString); -ClassicAssert.IsEmpty(string aString, string message, params object[] args); +Assert.IsEmpty(string aString); +Assert.IsEmpty(string aString, string message, params object[] args); -ClassicAssert.IsEmpty(IEnumerable collection); -ClassicAssert.IsEmpty(IEnumerable collection, string message, +Assert.IsEmpty(IEnumerable collection); +Assert.IsEmpty(IEnumerable collection, string message, params object[] args); ``` > [!NOTE] -> When used with an IEnumerable that is not also an ICollection, **ClassicAssert.IsEmpty** attempts to enumerate +> When used with an IEnumerable that is not also an ICollection, **Assert.IsEmpty** attempts to enumerate > the contents. It should not be used in cases where this results in an unwanted side effect. ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md index 25f2282e4..c09da57ea 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md @@ -1,13 +1,19 @@ -# ClassicAssert.IsInstanceOf +# Assert.IsInstanceOf -**ClassicAssert.IsInstanceOf** succeeds if the object provided as an actual value is an instance of the expected type. +**Assert.IsInstanceOf** succeeds if the object provided as an actual value is an instance of the expected type. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.IsInstanceOf(Type expected, object actual); -ClassicAssert.IsInstanceOf(Type expected, object actual, +Assert.IsInstanceOf(Type expected, object actual); +Assert.IsInstanceOf(Type expected, object actual, string message, params object[] params); -ClassicAssert.IsInstanceOf(object actual); -ClassicAssert.IsInstanceOf(object actual, +Assert.IsInstanceOf(object actual); +Assert.IsInstanceOf(object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md index 8c98f27a1..8e2037a12 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md @@ -1,10 +1,16 @@ -# ClassicAssert.IsNaN +# Assert.IsNaN -**ClassicAssert.IsNaN** tests that the specified double value is NaN. +**Assert.IsNaN** tests that the specified double value is NaN. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.IsNaN(double aDouble); -ClassicAssert.IsNaN(double aDouble, string message, params object[] params); +Assert.IsNaN(double aDouble); +Assert.IsNaN(double aDouble, string message, params object[] params); ``` ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md index 959d25ac8..02bf97183 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md @@ -1,13 +1,19 @@ -# ClassicAssert.IsNotAssignableFrom +# Assert.IsNotAssignableFrom -**ClassicAssert.IsNotAssignableFrom** succeeds if the object provided may not be assigned a value of the expected type. +**Assert.IsNotAssignableFrom** succeeds if the object provided may not be assigned a value of the expected type. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.IsNotAssignableFrom(Type expected, object actual); -ClassicAssert.IsNotAssignableFrom(Type expected, object actual, +Assert.IsNotAssignableFrom(Type expected, object actual); +Assert.IsNotAssignableFrom(Type expected, object actual, string message, params object[] params); -ClassicAssert.IsNotAssignableFrom(object actual); -ClassicAssert.IsNotAssignableFrom(object actual, +Assert.IsNotAssignableFrom(object actual); +Assert.IsNotAssignableFrom(object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md index d0c5a5237..0a8647352 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md @@ -1,20 +1,26 @@ -# ClassicAssert.IsNotEmpty +# Assert.IsNotEmpty -**ClassicAssert.IsNotEmpty** may be used to test either a string or a collection or IEnumerable. When used with a +**Assert.IsNotEmpty** may be used to test either a string or a collection or IEnumerable. When used with a string, it succeeds if the string is not the empty string. When used with a collection, it succeeds if the collection is not empty. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.IsNotEmpty(string aString); -ClassicAssert.IsNotEmpty(string aString, string message, params object[] args); +Assert.IsNotEmpty(string aString); +Assert.IsNotEmpty(string aString, string message, params object[] args); -ClassicAssert.IsNotEmpty(IEnumerable collection); -ClassicAssert.IsNotEmpty(IEnumerable collection, string message, +Assert.IsNotEmpty(IEnumerable collection); +Assert.IsNotEmpty(IEnumerable collection, string message, params object[] args); ``` > [!NOTE] -> When used with an IEnumerable that is not also an ICollection, **ClassicAssert.IsEmpty** attempts to enumerate +> When used with an IEnumerable that is not also an ICollection, **Assert.IsEmpty** attempts to enumerate > the contents. It should not be used in cases where this results in an unwanted side effect. ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md index c03f829e5..18050c792 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md @@ -1,13 +1,19 @@ -# ClassicAssert.IsNotInstanceOf +# Assert.IsNotInstanceOf -**ClassicAssert.IsNotInstanceOf** succeeds if the object provided as an actual value is not an instance of the expected type. +**Assert.IsNotInstanceOf** succeeds if the object provided as an actual value is not an instance of the expected type. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.IsNotInstanceOf(Type expected, object actual); -ClassicAssert.IsNotInstanceOf(Type expected, object actual, +Assert.IsNotInstanceOf(Type expected, object actual); +Assert.IsNotInstanceOf(Type expected, object actual, string message, params object[] params); -ClassicAssert.IsNotInstanceOf(object actual); -ClassicAssert.IsNotInstanceOf(object actual, +Assert.IsNotInstanceOf(object actual); +Assert.IsNotInstanceOf(object actual, string message, params object[] params); ``` diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md index d4f0704ba..9965a6f9c 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md @@ -1,43 +1,49 @@ -# ClassicAssert.Less +# Assert.Less -**ClassicAssert.Less** tests whether one object is less than another. +**Assert.Less** tests whether one object is less than another. Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus -**ClassicAssert.Less(x, y)** asserts that x is less than y (x < y). +**Assert.Less(x, y)** asserts that x is less than y (x < y). + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.Less(int arg1, int arg2); -ClassicAssert.Less(int arg1, int arg2, string message, params object[] params); +Assert.Less(int arg1, int arg2); +Assert.Less(int arg1, int arg2, string message, params object[] params); -ClassicAssert.Less(uint arg1, uint arg2); -ClassicAssert.Less(uint arg1, uint arg2, string message, params object[] params); +Assert.Less(uint arg1, uint arg2); +Assert.Less(uint arg1, uint arg2, string message, params object[] params); -ClassicAssert.Less(long arg1, long arg2); -ClassicAssert.Less(long arg1, long arg2, string message, params object[] params); +Assert.Less(long arg1, long arg2); +Assert.Less(long arg1, long arg2, string message, params object[] params); -ClassicAssert.Less(ulong arg1, ulong arg2); -ClassicAssert.Less(ulong arg1, ulong arg2, string message, params object[] params); +Assert.Less(ulong arg1, ulong arg2); +Assert.Less(ulong arg1, ulong arg2, string message, params object[] params); -ClassicAssert.Less(decimal arg1, decimal arg2); -ClassicAssert.Less(decimal arg1, decimal arg2, +Assert.Less(decimal arg1, decimal arg2); +Assert.Less(decimal arg1, decimal arg2, string message, params object[] params); -ClassicAssert.Less(double arg1, double arg2); -ClassicAssert.Less(double arg1, double arg2, +Assert.Less(double arg1, double arg2); +Assert.Less(double arg1, double arg2, string message, params object[] params); -ClassicAssert.Less(float arg1, float arg2); -ClassicAssert.Less(float arg1, float arg2, +Assert.Less(float arg1, float arg2); +Assert.Less(float arg1, float arg2, string message, params object[] params); -ClassicAssert.Less(IComparable arg1, IComparable arg2); -ClassicAssert.Less(IComparable arg1, IComparable arg2, +Assert.Less(IComparable arg1, IComparable arg2); +Assert.Less(IComparable arg1, IComparable arg2, string message, params object[] params); ``` ## See Also -* [ClassicAssert.Greater](Assert.Greater.md) -* [ClassicAssert.GreaterOrEqual](Assert.GreaterOrEqual.md) -* [ClassicAssert.LessOrEqual](Assert.LessOrEqual.md) +* [Assert.Greater](Assert.Greater.md) +* [Assert.GreaterOrEqual](Assert.GreaterOrEqual.md) +* [Assert.LessOrEqual](Assert.LessOrEqual.md) * [Comparison Constraints](xref:constraints#comparison-constraints) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md index fff4b9aef..2abeb5771 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md @@ -1,47 +1,53 @@ -# ClassicAssert.LessOrEqual +# Assert.LessOrEqual -**ClassicAssert.LessOrEqual** tests whether one object is less than or equal to another. +**Assert.LessOrEqual** tests whether one object is less than or equal to another. Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus -**ClassicAssert.LessOrEqual(x, y)** asserts that x is less than or equal to y (x <= y). +**Assert.LessOrEqual(x, y)** asserts that x is less than or equal to y (x <= y). + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.LessOrEqual(int arg1, int arg2); -ClassicAssert.LessOrEqual(int arg1, int arg2, +Assert.LessOrEqual(int arg1, int arg2); +Assert.LessOrEqual(int arg1, int arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(uint arg1, uint arg2); -ClassicAssert.LessOrEqual(uint arg1, uint arg2, +Assert.LessOrEqual(uint arg1, uint arg2); +Assert.LessOrEqual(uint arg1, uint arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(long arg1, long arg2); -ClassicAssert.LessOrEqual(long arg1, long arg2, +Assert.LessOrEqual(long arg1, long arg2); +Assert.LessOrEqual(long arg1, long arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(ulong arg1, ulong arg2); -ClassicAssert.LessOrEqual(ulong arg1, ulong arg2, +Assert.LessOrEqual(ulong arg1, ulong arg2); +Assert.LessOrEqual(ulong arg1, ulong arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(decimal arg1, decimal arg2); -ClassicAssert.LessOrEqual(decimal arg1, decimal arg2, +Assert.LessOrEqual(decimal arg1, decimal arg2); +Assert.LessOrEqual(decimal arg1, decimal arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(double arg1, double arg2); -ClassicAssert.LessOrEqual(double arg1, double arg2, +Assert.LessOrEqual(double arg1, double arg2); +Assert.LessOrEqual(double arg1, double arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(float arg1, float arg2); -ClassicAssert.LessOrEqual(float arg1, float arg2, +Assert.LessOrEqual(float arg1, float arg2); +Assert.LessOrEqual(float arg1, float arg2, string message, params object[] params); -ClassicAssert.LessOrEqual(IComparable arg1, IComparable arg2); -ClassicAssert.LessOrEqual(IComparable arg1, IComparable arg2, +Assert.LessOrEqual(IComparable arg1, IComparable arg2); +Assert.LessOrEqual(IComparable arg1, IComparable arg2, string message, params object[] params); ``` ## See Also -* [ClassicAssert.Greater](Assert.Greater.md) -* [ClassicAssert.GreaterOrEqual](Assert.GreaterOrEqual.md) -* [ClassicAssert.Less](Assert.Less.md) +* [Assert.Greater](Assert.Greater.md) +* [Assert.GreaterOrEqual](Assert.GreaterOrEqual.md) +* [Assert.Less](Assert.Less.md) * [Comparison Constraints](xref:constraints#comparison-constraints) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md index ca0e8206f..da022b7d3 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md @@ -1,44 +1,50 @@ -# ClassicAssert.Negative +# Assert.Negative Asserts that a number is negative. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp //true -ClassicAssert.Negative(-1); +Assert.Negative(-1); //false -ClassicAssert.Negative(1); +Assert.Negative(1); ``` All the overloads of the method are ```csharp -ClassicAssert.Negative(int actual); -ClassicAssert.Negative(int actual, string message, params object[] args); +Assert.Negative(int actual); +Assert.Negative(int actual, string message, params object[] args); -ClassicAssert.Negative(uint actual); -ClassicAssert.Negative(uint actual, string message, params object[] args); +Assert.Negative(uint actual); +Assert.Negative(uint actual, string message, params object[] args); -ClassicAssert.Negative(long actual); -ClassicAssert.Negative(long actual, string message, params object[] args); +Assert.Negative(long actual); +Assert.Negative(long actual, string message, params object[] args); -ClassicAssert.Negative(ulong actual); -ClassicAssert.Negative(ulong actual, string message, params object[] args); +Assert.Negative(ulong actual); +Assert.Negative(ulong actual, string message, params object[] args); -ClassicAssert.Negative(decimal actual); -ClassicAssert.Negative(decimal actual, string message, params object[] args); +Assert.Negative(decimal actual); +Assert.Negative(decimal actual, string message, params object[] args); -ClassicAssert.Negative(double actual); -ClassicAssert.Negative(double actual, string message, params object[] args); +Assert.Negative(double actual); +Assert.Negative(double actual, string message, params object[] args); -ClassicAssert.Negative(float actual); -ClassicAssert.Negative(float actual, string message, params object[] args); +Assert.Negative(float actual); +Assert.Negative(float actual, string message, params object[] args); ``` -You may also use **ClassicAssert.That** with a **Is.Negative** constraint to achieve the same result. +You may also use **Assert.That** with a **Is.Negative** constraint to achieve the same result. ## See Also -* [ClassicAssert.Positive](Assert.Positive.md) -* [ClassicAssert.Zero](Assert.Zero.md) -* [ClassicAssert.NotZero](Assert.NotZero.md) -* [ClassicAssert.IsNaN](Assert.IsNaN.md) +* [Assert.Positive](Assert.Positive.md) +* [Assert.Zero](Assert.Zero.md) +* [Assert.NotZero](Assert.NotZero.md) +* [Assert.IsNaN](Assert.IsNaN.md) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md index a4b33dcc6..a6d02ca95 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md @@ -1,15 +1,21 @@ -# ClassicAssert.NotNull +# Assert.NotNull -**ClassicAssert.NotNull** and **ClassicAssert.IsNotNull** test that the specified object is non-null. +**Assert.NotNull** and **Assert.IsNotNull** test that the specified object is non-null. The two forms are provided for compatibility with past versions of NUnit and NUnitLite. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.NotNull(object anObject); -ClassicAssert.NotNull(object anObject, string message, params object[] params); +Assert.NotNull(object anObject); +Assert.NotNull(object anObject, string message, params object[] params); -ClassicAssert.IsNotNull(object anObject); -ClassicAssert.IsNotNull(object anObject, string message, params object[] params); +Assert.IsNotNull(object anObject); +Assert.IsNotNull(object anObject, string message, params object[] params); ``` ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md index f22281182..36c4b7365 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md @@ -1,29 +1,35 @@ -# ClassicAssert.NotZero +# Assert.NotZero -**ClassicAssert.NotZero** tests that a value is not zero. +**Assert.NotZero** tests that a value is not zero. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.NotZero(int actual); -ClassicAssert.NotZero(int actual, string message, params object[] args); +Assert.NotZero(int actual); +Assert.NotZero(int actual, string message, params object[] args); -ClassicAssert.NotZero(uint actual); -ClassicAssert.NotZero(uint actual, string message, params object[] args); +Assert.NotZero(uint actual); +Assert.NotZero(uint actual, string message, params object[] args); -ClassicAssert.NotZero(long actual); -ClassicAssert.NotZero(long actual, string message, params object[] args); +Assert.NotZero(long actual); +Assert.NotZero(long actual, string message, params object[] args); -ClassicAssert.NotZero(ulong actual); -ClassicAssert.NotZero(ulong actual, string message, params object[] args); +Assert.NotZero(ulong actual); +Assert.NotZero(ulong actual, string message, params object[] args); -ClassicAssert.NotZero(decimal actual); -ClassicAssert.NotZero(decimal actual, string message, params object[] args); +Assert.NotZero(decimal actual); +Assert.NotZero(decimal actual, string message, params object[] args); -ClassicAssert.NotZero(double actual); -ClassicAssert.NotZero(double actual, string message, params object[] args); +Assert.NotZero(double actual); +Assert.NotZero(double actual, string message, params object[] args); -ClassicAssert.NotZero(float actual); -ClassicAssert.NotZero(float actual, string message, params object[] args); +Assert.NotZero(float actual); +Assert.NotZero(float actual, string message, params object[] args); ``` -You may also use **ClassicAssert.That** with a `Is.Not.Zero` constraint to achieve the +You may also use **Assert.That** with a `Is.Not.Zero` constraint to achieve the same result. diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md index 25ca8fc06..b92b7896a 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md @@ -1,15 +1,21 @@ -# ClassicAssert.Null +# Assert.Null -**ClassicAssert.Null** and **ClassicAssert.IsNull** test that the specified object is null. +**Assert.Null** and **Assert.IsNull** test that the specified object is null. The two forms are provided for compatibility with past versions of NUnit and NUnitLite. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.Null(object anObject); -ClassicAssert.Null(object anObject, string message, params object[] params); +Assert.Null(object anObject); +Assert.Null(object anObject, string message, params object[] params); -ClassicAssert.IsNull(object anObject); -ClassicAssert.IsNull(object anObject, string message, params object[] params); +Assert.IsNull(object anObject); +Assert.IsNull(object anObject, string message, params object[] params); ``` ## See Also diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md index b0b240c92..b5e7f90d4 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md @@ -1,44 +1,50 @@ -# ClassicAssert.Positive +# Assert.Positive Asserts that a number is positive. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp //false -ClassicAssert.Positive(-1); +Assert.Positive(-1); //true -ClassicAssert.Positive(1); +Assert.Positive(1); ``` All the overloads of the method are ```csharp -ClassicAssert.Positive(int actual); -ClassicAssert.Positive(int actual, string message, params object[] args); +Assert.Positive(int actual); +Assert.Positive(int actual, string message, params object[] args); -ClassicAssert.Positive(uint actual); -ClassicAssert.Positive(uint actual, string message, params object[] args); +Assert.Positive(uint actual); +Assert.Positive(uint actual, string message, params object[] args); -ClassicAssert.Positive(long actual); -ClassicAssert.Positive(long actual, string message, params object[] args); +Assert.Positive(long actual); +Assert.Positive(long actual, string message, params object[] args); -ClassicAssert.Positive(ulong actual); -ClassicAssert.Positive(ulong actual, string message, params object[] args); +Assert.Positive(ulong actual); +Assert.Positive(ulong actual, string message, params object[] args); -ClassicAssert.Positive(decimal actual); -ClassicAssert.Positive(decimal actual, string message, params object[] args); +Assert.Positive(decimal actual); +Assert.Positive(decimal actual, string message, params object[] args); -ClassicAssert.Positive(double actual); -ClassicAssert.Positive(double actual, string message, params object[] args); +Assert.Positive(double actual); +Assert.Positive(double actual, string message, params object[] args); -ClassicAssert.Positive(float actual); -ClassicAssert.Positive(float actual, string message, params object[] args); +Assert.Positive(float actual); +Assert.Positive(float actual, string message, params object[] args); ``` -You may also use **ClassicAssert.That** with a **Is.Positive** constraint to achieve the same result. +You may also use **Assert.That** with a **Is.Positive** constraint to achieve the same result. ## See Also -* [ClassicAssert.Negative](Assert.Negative.md) -* [ClassicAssert.Zero](Assert.Zero.md) -* [ClassicAssert.NotZero](Assert.NotZero.md) -* [ClassicAssert.IsNaN](Assert.IsNaN.md) +* [Assert.Negative](Assert.Negative.md) +* [Assert.Zero](Assert.Zero.md) +* [Assert.NotZero](Assert.NotZero.md) +* [Assert.IsNaN](Assert.IsNaN.md) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md index 1d9117e46..c8ae6a73f 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md @@ -1,15 +1,21 @@ -# ClassicAssert.True +# Assert.True -**ClassicAssert.True** and **ClassicAssert.IsTrue** test that the specified condition is true. +**Assert.True** and **Assert.IsTrue** test that the specified condition is true. The two forms are provided for compatibility with past versions of NUnit and NUnitLite. +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. + ```csharp -ClassicAssert.True(bool condition); -ClassicAssert.True(bool condition, string message, params object[] params); +Assert.True(bool condition); +Assert.True(bool condition, string message, params object[] params); -ClassicAssert.IsTrue(bool condition); -ClassicAssert.IsTrue(bool condition, string message, params object[] params); +Assert.IsTrue(bool condition); +Assert.IsTrue(bool condition, string message, params object[] params); ``` You can also use **Assert.That** with a Boolean argument to achieve the diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md index cff490391..312f7d507 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md @@ -1,28 +1,34 @@ -# ClassicAssert.Zero +# Assert.Zero -**ClassicAssert.Zero** tests that a value is zero. +**Assert.Zero** tests that a value is zero. + +:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +NUnit.Framework.Legacy namespace. ```csharp -ClassicAssert.Zero(int actual); -ClassicAssert.Zero(int actual, string message, params object[] args); +Assert.Zero(int actual); +Assert.Zero(int actual, string message, params object[] args); -ClassicAssert.Zero(uint actual); -ClassicAssert.Zero(uint actual, string message, params object[] args); +Assert.Zero(uint actual); +Assert.Zero(uint actual, string message, params object[] args); -ClassicAssert.Zero(long actual); -ClassicAssert.Zero(long actual, string message, params object[] args); +Assert.Zero(long actual); +Assert.Zero(long actual, string message, params object[] args); -ClassicAssert.Zero(ulong actual); -ClassicAssert.Zero(ulong actual, string message, params object[] args); +Assert.Zero(ulong actual); +Assert.Zero(ulong actual, string message, params object[] args); -ClassicAssert.Zero(decimal actual); -ClassicAssert.Zero(decimal actual, string message, params object[] args); +Assert.Zero(decimal actual); +Assert.Zero(decimal actual, string message, params object[] args); -ClassicAssert.Zero(double actual); -ClassicAssert.Zero(double actual, string message, params object[] args); +Assert.Zero(double actual); +Assert.Zero(double actual, string message, params object[] args); -ClassicAssert.Zero(float actual); -ClassicAssert.Zero(float actual, string message, params object[] args); +Assert.Zero(float actual); +Assert.Zero(float actual, string message, params object[] args); ``` You may also use **Assert.That** with a Is.Zero constraint to achieve the diff --git a/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs b/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs index fdecdde24..0f4a94cdf 100644 --- a/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs +++ b/docs/snippets/Snippets.NUnit/ClassicAssertExamples.cs @@ -17,19 +17,19 @@ public class ClassicAssertExamples public void AreEqual_Examples() { // Comparing numerics of different types - ClassicAssert.AreEqual(5, 5.0); + Assert.AreEqual(5, 5.0); // Floating point special values - ClassicAssert.AreEqual(double.PositiveInfinity, double.PositiveInfinity); - ClassicAssert.AreEqual(double.NegativeInfinity, double.NegativeInfinity); - ClassicAssert.AreEqual(double.NaN, double.NaN); + Assert.AreEqual(double.PositiveInfinity, double.PositiveInfinity); + Assert.AreEqual(double.NegativeInfinity, double.NegativeInfinity); + Assert.AreEqual(double.NaN, double.NaN); // Basic equality - ClassicAssert.AreEqual("expected", "expected"); - ClassicAssert.AreEqual(42, 42); + Assert.AreEqual("expected", "expected"); + Assert.AreEqual(42, 42); // With tolerance for floating point - ClassicAssert.AreEqual(2.1 + 1.2, 3.3, 0.001); + Assert.AreEqual(2.1 + 1.2, 3.3, 0.001); } #endregion @@ -37,9 +37,9 @@ public void AreEqual_Examples() [Test] public void AreNotEqual_Examples() { - ClassicAssert.AreNotEqual(5, 3); - ClassicAssert.AreNotEqual("Hello", "World"); - ClassicAssert.AreNotEqual(null, "something"); + Assert.AreNotEqual(5, 3); + Assert.AreNotEqual("Hello", "World"); + Assert.AreNotEqual(null, "something"); } #endregion @@ -58,9 +58,9 @@ public void True_Examples() [Test] public void False_Examples() { - ClassicAssert.False(2 + 2 == 5); - ClassicAssert.IsFalse(false); - ClassicAssert.False("Hello".StartsWith("X")); + Assert.False(2 + 2 == 5); + Assert.IsFalse(false); + Assert.False("Hello".StartsWith("X")); } #endregion From 2f84bd868b41e494124844ed776be599385356d0 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 20:29:45 +0100 Subject: [PATCH 03/12] Updated documentation for classic asserts --- .../writing-tests/assertions/assertion-models/classic.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md index 992900fbe..9332a4907 100644 --- a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md @@ -15,15 +15,15 @@ StringAssert.AreEqualIgnoringCase("Hello", myString); :NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier version, replace Assert with ClassicAssert and include the +syntax will be used. If you use an earlier 4.X version, replace Assert with ClassicAssert and include the NUnit.Framework.Legacy namespace. :NOTE: The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code that already use this. -:NOTE: The use of See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. +:NOTE: See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. -The Assert class provides the most common assertions in NUnit: +The Assert class provides the most common classic assertions in NUnit: * [Assert.True](../classic-assertions/Assert.True.md) * [Assert.False](../classic-assertions/Assert.False.md) From cd476b8c3c2d401478cfef567541409761799958 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:02:04 +0100 Subject: [PATCH 04/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../assertions/classic-assertions/Assert.Zero.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md index 312f7d507..8800a4e05 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Zero.md @@ -2,11 +2,12 @@ **Assert.Zero** tests that a value is zero. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.Zero(int actual); From 4b6580cbbd6252cf67cc687ba1d44434074c74fb Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:02:18 +0100 Subject: [PATCH 05/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../assertions/assertion-models/classic.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md index 9332a4907..04b4468c8 100644 --- a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md @@ -12,16 +12,19 @@ Here's a simple assert using the classic model: StringAssert.AreEqualIgnoringCase("Hello", myString); ``` -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.X version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.X version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. -:NOTE: The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code -that already use this. +> [!NOTE] +> The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code +> that already use this. -:NOTE: See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. +> [!NOTE] +> See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. The Assert class provides the most common classic assertions in NUnit: From a5146e7e00761db530b2f790a40496bd9edcbd6e Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:02:35 +0100 Subject: [PATCH 06/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../assertions/classic-assertions/Assert.Positive.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md index b5e7f90d4..b9cc9b8d5 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Positive.md @@ -2,11 +2,11 @@ Asserts that a number is positive. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy namespace, +> but can use the former Assert class. This applies for many of the asserts, but a few still require the use of the ClassicAssert +> class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 syntax will be used. If you +> use an earlier 4.x version, replace Assert with ClassicAssert and include the NUnit.Framework.Legacy namespace. ```csharp //false From 37ab030c968dfa09cc3f752cbb9e9024e6cd7ed3 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:02:54 +0100 Subject: [PATCH 07/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../assertions/classic-assertions/Assert.IsEmpty.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md index e970a2272..525bc3481 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsEmpty.md @@ -3,11 +3,12 @@ **Assert.IsEmpty** may be used to test either a string or a collection or IEnumerable. When used with a string, it succeeds if the string is the empty string. When used with a collection, it succeeds if the collection is empty. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsEmpty(string aString); From 16f7c3495abc3656fbd44d20faf3e04a3bd3ea95 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:03:04 +0100 Subject: [PATCH 08/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../classic-assertions/Assert.IsNotAssignableFrom.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md index 02bf97183..d28d1a10d 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotAssignableFrom.md @@ -2,11 +2,12 @@ **Assert.IsNotAssignableFrom** succeeds if the object provided may not be assigned a value of the expected type. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsNotAssignableFrom(Type expected, object actual); From 06dc223ec4fbabb5884c111bb31c9e12423f4d50 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:03:17 +0100 Subject: [PATCH 09/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../assertions/classic-assertions/Assert.NotZero.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md index 36c4b7365..784efb7ad 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotZero.md @@ -2,11 +2,12 @@ **Assert.NotZero** tests that a value is not zero. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.NotZero(int actual); From 4310c4e1f9d16a1e8d1e665cbb8eae29a76382bf Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:11:55 +0100 Subject: [PATCH 10/12] fixed note --- .../assertions/classic-assertions/Assert.AreEqual.md | 11 ++++++----- .../classic-assertions/Assert.AreNotEqual.md | 11 ++++++----- .../classic-assertions/Assert.AreNotSame.md | 11 ++++++----- .../assertions/classic-assertions/Assert.AreSame.md | 11 ++++++----- .../assertions/classic-assertions/Assert.Contains.md | 11 ++++++----- .../assertions/classic-assertions/Assert.False.md | 11 ++++++----- .../assertions/classic-assertions/Assert.Greater.md | 11 ++++++----- .../classic-assertions/Assert.GreaterOrEqual.md | 11 ++++++----- .../classic-assertions/Assert.IsAssignableFrom.md | 11 ++++++----- .../classic-assertions/Assert.IsInstanceOf.md | 11 ++++++----- .../assertions/classic-assertions/Assert.IsNaN.md | 11 ++++++----- .../classic-assertions/Assert.IsNotEmpty.md | 11 ++++++----- .../classic-assertions/Assert.IsNotInstanceOf.md | 11 ++++++----- .../assertions/classic-assertions/Assert.Less.md | 11 ++++++----- .../classic-assertions/Assert.LessOrEqual.md | 11 ++++++----- .../assertions/classic-assertions/Assert.Negative.md | 11 ++++++----- .../assertions/classic-assertions/Assert.NotNull.md | 11 ++++++----- .../assertions/classic-assertions/Assert.Null.md | 11 ++++++----- .../assertions/classic-assertions/Assert.True.md | 11 ++++++----- 19 files changed, 114 insertions(+), 95 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md index 7a649dd0a..ec9fddf7e 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.md @@ -2,11 +2,12 @@ **Assert.AreEqual** tests whether the two arguments are equal. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.AreEqual(double expected, double actual, double tolerance); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md index 2e7f1f7f2..cace3a4df 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotEqual.md @@ -2,11 +2,12 @@ **Assert.AreNotEqual** tests whether the two arguments are unequal. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.AreNotEqual(object expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md index 72301ce78..2e4e65d40 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreNotSame.md @@ -2,11 +2,12 @@ **Assert.AreNotSame** tests that the two arguments do not reference the same object. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.AreNotSame(object expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md index a9478d962..6074cd707 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreSame.md @@ -2,11 +2,12 @@ **Assert.AreSame** tests that the two arguments reference the same object. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.AreSame(object expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md index 435669b77..ab5973af6 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Contains.md @@ -3,11 +3,12 @@ **Assert.Contains** is used to test whether an object is contained in a collection. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.Contains(object anObject, ICollection collection); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md index 036194b42..762eb666b 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.False.md @@ -4,11 +4,12 @@ The two forms are provided for compatibility with past versions of NUnit and NUnitLite. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.False(bool condition); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md index 0d0ac8791..ff48a8939 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Greater.md @@ -5,11 +5,12 @@ Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus **Assert.Greater(x, y)** asserts that x is greater than y (x > y). -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.Greater(int arg1, int arg2); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md index 7bcb34984..da360ffb5 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.GreaterOrEqual.md @@ -5,11 +5,12 @@ Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus **Assert.GreaterOrEqual(x, y)** asserts that x is greater than or equal to y (x >= y). -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.GreaterOrEqual(int arg1, int arg2); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md index a21b9e473..c8c7fd8ea 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsAssignableFrom.md @@ -2,11 +2,12 @@ **Assert.IsAssignableFrom** succeeds if the object provided may be assigned a value of the expected type. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsAssignableFrom(Type expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md index c09da57ea..8cc47c3bd 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsInstanceOf.md @@ -2,11 +2,12 @@ **Assert.IsInstanceOf** succeeds if the object provided as an actual value is an instance of the expected type. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsInstanceOf(Type expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md index 8e2037a12..ad4644325 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNaN.md @@ -2,11 +2,12 @@ **Assert.IsNaN** tests that the specified double value is NaN. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsNaN(double aDouble); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md index 0a8647352..479cf32f2 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotEmpty.md @@ -4,11 +4,12 @@ string, it succeeds if the string is not the empty string. When used with a collection, it succeeds if the collection is not empty. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsNotEmpty(string aString); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md index 18050c792..cef2dceef 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.IsNotInstanceOf.md @@ -2,11 +2,12 @@ **Assert.IsNotInstanceOf** succeeds if the object provided as an actual value is not an instance of the expected type. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.IsNotInstanceOf(Type expected, object actual); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md index 9965a6f9c..62ef96932 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Less.md @@ -5,11 +5,12 @@ Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus **Assert.Less(x, y)** asserts that x is less than y (x < y). -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.Less(int arg1, int arg2); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md index 2abeb5771..cbb95b200 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.LessOrEqual.md @@ -5,11 +5,12 @@ Contrary to the normal order of Asserts, these methods are designed to be read in the "natural" English-language or mathematical order. Thus **Assert.LessOrEqual(x, y)** asserts that x is less than or equal to y (x <= y). -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.LessOrEqual(int arg1, int arg2); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md index da022b7d3..fc061991d 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md @@ -2,11 +2,12 @@ Asserts that a number is negative. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp //true diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md index a6d02ca95..cd7db00e4 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.NotNull.md @@ -4,11 +4,12 @@ The two forms are provided for compatibility with past versions of NUnit and NUnitLite. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.NotNull(object anObject); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md index b92b7896a..e3575f72c 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Null.md @@ -4,11 +4,12 @@ The two forms are provided for compatibility with past versions of NUnit and NUnitLite. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.Null(object anObject); diff --git a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md index c8ae6a73f..aa1d35fa6 100644 --- a/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md +++ b/docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.True.md @@ -4,11 +4,12 @@ The two forms are provided for compatibility with past versions of NUnit and NUnitLite. -:NOTE: From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy -namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of -the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the -NUnit.Framework.Legacy namespace. +> [!NOTE] +> From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy +> namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of +> the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. ```csharp Assert.True(bool condition); From 217bc510db600a43034dbc3d01ac676d93bb8065 Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Sun, 15 Mar 2026 22:14:05 +0100 Subject: [PATCH 11/12] fixed note --- .../assertions/assertion-models/classic.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md index 04b4468c8..aa028e19e 100644 --- a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md @@ -16,14 +16,12 @@ StringAssert.AreEqualIgnoringCase("Hello", myString); > From version 4.5.0, using C# 14, you don't need to use the ClassicAssert class, nor the NUnit.Framework.Legacy > namespace, but can use the former Assert class. This applies for many of the asserts, but a few still require the use of > the ClassicAssert class. These will be fixed in upcoming releases. In the list below, and in the examples, the 4.5.0 -> syntax will be used. If you use an earlier 4.X version, replace Assert with ClassicAssert and include the -> NUnit.Framework.Legacy namespace. - -> [!NOTE] +> syntax will be used. If you use an earlier 4.x version, replace Assert with ClassicAssert and include the +> NUnit.Framework.Legacy namespace. +> > The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code > that already use this. - -> [!NOTE] +> > See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. The Assert class provides the most common classic assertions in NUnit: From c8064e9e56649fc614b9a3ab78209e90f5aa37aa Mon Sep 17 00:00:00 2001 From: Terje Sandstrom Date: Mon, 16 Mar 2026 10:55:28 +0100 Subject: [PATCH 12/12] fix broken link --- .../nunit/writing-tests/assertions/assertion-models/classic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md index aa028e19e..c4b2ba2a7 100644 --- a/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md +++ b/docs/articles/nunit/writing-tests/assertions/assertion-models/classic.md @@ -22,7 +22,7 @@ StringAssert.AreEqualIgnoringCase("Hello", myString); > The `ClassicAssert` and `NUnit.Framework.Legacy` are still available in 4.5.0, so you don't need to change code > that already use this. > -> See [classic extensions](../classic_extensions.md) for a full table over all extension mappings. +> See [classic extensions](classic_extensions.md) for a full table over all extension mappings. The Assert class provides the most common classic assertions in NUnit: