Common NUnit…
Here’s a consolidated list of common NUnit Assert statements, categorized by their purpose. This should cover most of the common scenarios: Basic Assertions Equality: Assert.That(actual, Is.EqualTo(expected)); Assert.That(actual, Is.Not.EqualTo(expected)); Boolean Conditions: Assert.That(condition, Is.True); Assert.That(condition, Is.False); Null Checks: Assert.That(obj, Is.Null); Assert.That(obj, Is.Not.Null); String Assertions Contains: Assert.That(actualString, Does.Contain(substring)); Starts With / Ends With: Assert.That(actualString, Does.StartWith(prefix)); Assert.That(actualString, Does.EndWith(suffix)); Empty or Not Empty: Assert.That(actualString, Is.Empty); Assert.That(actualString, Is.Not.Empty); Matches Regex: Assert.That(actualString, Does.Match(regexPattern)); Collection Assertions Contains Item: Assert.That(collection, Does.Contain(item)); Has Specific Count: Assert.That(collection, Has.Count.EqualTo(expectedCount)); Empty or Not Empty: Assert.That(collection,…
Permanent link to “Common NUnit `Assert` statements”