AssertWithIs 1.0.0
See the version list below for details.
dotnet add package AssertWithIs --version 1.0.0
NuGet\Install-Package AssertWithIs -Version 1.0.0
<PackageReference Include="AssertWithIs" Version="1.0.0" />
<PackageVersion Include="AssertWithIs" Version="1.0.0" />
<PackageReference Include="AssertWithIs" />
paket add AssertWithIs --version 1.0.0
#r "nuget: AssertWithIs, 1.0.0"
#:package AssertWithIs@1.0.0
#addin nuget:?package=AssertWithIs&version=1.0.0
#tool nuget:?package=AssertWithIs&version=1.0.0
๐ฆ Is โ Minimalistic Assertion Extensions for .NET
Simple. Readable. Opinionated.
Is
is a lightweight assertion library for .NET that focuses on readable, minimal, and fail-fast test expectations โ no assertion clutter, no dependencies, no test framework lock-in.
โ Why use Is?
- ๐ Concise: One word. One assertion.
- ๐ฅ Opinionated: No "IsNot", only assert what you expect, not what you not expect, just fast failure and clarity.
- ๐งช Test-framework agnostic: Works with xUnit, NUnit, MSTest, or none at all.
- โ๏ธ Self-contained: No dependencies, no configuration, just drop it in.
๐ Available Methods
All public methods in Is
are:
- โ๏ธ Extension methods, designed to be used fluently (
value.Is(...)
) - ๐ค Named consistently: Every method starts with
Is
, making them easy to discover with IntelliSense - โ๏ธ Minimal and deliberate: Only a small, opinionated set of assertions is exposed
Method Categories
Exception Assertions
Methods that assert conditions related to exceptions.
Method | Description |
---|---|
IsThrowing<T>(Action action) |
Asserts that the given synchronous action throws an exception of type T . Returns the exception. |
IsThrowing<T>(Func<Task> action) |
Asserts that the given asynchronous function throws an exception of type T . Returns the exception. |
IsThrowing<T>(Action action, string message) |
Asserts that the given synchronous action throws an exception of type T and that the exception message contains the specified substring. |
IsThrowing<T>(Func<Task> action, string message) |
Asserts that the given asynchronous function throws an exception of type T and that the exception message contains the specified substring. |
Type Assertions
Methods that assert conditions related to the type of an object.
Method | Description |
---|---|
Is<T>(object actual) |
Asserts that the actual object is of type T . Returns the cast object to the type T . |
IsNot<T>(object actual) |
Asserts that the actual object is not of type T . |
Equality Assertions
Methods that assert conditions related to equality.
Method | Description |
---|---|
IsExactly<T>(T actual, T expected) |
Asserts that the actual object is exactly equal to the expected value. |
Is(object actual, params object[] expected) |
Asserts that the actual object matches the expected value(s). |
IsNot<T>(T actual, T expected) |
Asserts that the actual value is not equal to the expected value. |
IsSameAs<T>(T actual, T expected) |
Asserts that the actual object is the same instance as the expected object. |
IsDefault<T>(T actual) |
Asserts that the actual value is the default value of its type. |
IsSatisfying<T>(T actual, Func<T, bool> predicate) |
Asserts that the actual object satisfies the specified predicate. |
Collection Assertions
Methods that assert conditions related to collections and sequences.
Method | Description |
---|---|
IsEmpty<T>(IEnumerable<T> actual) |
Asserts that the sequence is empty. |
IsContaining<T>(IEnumerable<T> actual, params T[] expected) |
Asserts that the sequence contains all the specified elements. |
IsIn<T>(IEnumerable<T> actual, params T[] expected) |
Asserts that all elements in the actual collection are present in the expected collection. |
IsEquivalentTo<T>(IEnumerable<T> actual, IEnumerable<T> expected) |
Asserts that the sequence matches the specified values ignoring item order. |
IsUnique<T>(IEnumerable<T> actual, IEnumerable<T> expected) |
Asserts that all elements in the sequence are unique. |
Comparison Assertions
Methods that assert conditions related to comparisons.
Method | Description |
---|---|
IsApproximately<T>(T actual, T expected, T epsilon) |
Asserts that the actual floating point is approximately equal to the expected value within a specified epsilon. |
IsApproximately<T>(T actual, T expected) |
Asserts that the actual floating point is approximately equal to the expected value with a default epsilon of 1e-6 . |
IsGreaterThan<T>(T actual, T other) |
Asserts that the actual value is greater than the given other value. |
IsSmallerThan<T>(T actual, T other) |
Asserts that the actual value is smaller than the given other value. |
IsBetween<T>(T actual, T min, T max) |
Asserts that the actual value is between the specified min and max exclusive bounds. |
IsNotBetween<T>(T actual, T min, T max) |
Asserts that the actual value is not between the specified min and max exclusive bounds. |
IsAtLeast<T>(T actual, T other) |
Asserts that the actual value is greater or equal than the given other value. |
IsAtMost<T>(T actual, T other) |
Asserts that the actual value is smaller or equal than the given other value. |
IsInRange<T>(T actual, T min, T max) |
Asserts that the actual value is between the specified min and max inclusive bounds. |
IsPositive<T>(T actual) |
Asserts that the actual value is greater than zero. |
IsNegative<T>(T actual) |
Asserts that the actual value is smaller than zero. |
String Assertions
Methods that assert conditions related to strings.
Method | Description |
---|---|
IsContaining(string actual, string expected) |
Asserts that the actual string contains the specified substring. |
IsStartingWith(string actual, string expected) |
Asserts that the actual string starts with the specified substring. |
IsEndingWith(string actual, string expected) |
Asserts that the actual string ends with the specified substring. |
IsMatching(string actual, string pattern) |
Asserts that the actual string matches the specified regular expression pattern. Returns the match groups. |
IsNotMatching(string actual, string pattern) |
Asserts that the actual string does not match the specified regular expression pattern. |
Boolean Assertions
Methods that assert conditions related to boolean values.
Method | Description |
---|---|
IsTrue(bool actual) |
Asserts that a boolean value is true . |
IsFalse(bool actual) |
Asserts that a boolean value is false . |
Null Assertions
Methods that assert conditions related to null values.
Method | Description |
---|---|
IsNull(object actual) |
Asserts that an object is null . |
IsNotNull(object actual) |
Asserts that an object is not null . |
โ Because all methods start with
Is
, you can type.
and just filter byIs
in IntelliSense. Fast and frictionless.
๐ง Usage Examples
Basic value checks
42.Is(42); // โ
passes
42.Is(41); // โ throws IsNotException: 42 (System.Int32) is not 41 (System.Int32)
42.Is(42.0); // โ throws IsNotException: 42 (System.Int32) is not 42 (System.Double)
"test".Is("test"); // โ
passes
Collection checks
new[] { 1, 2, 3 }.Is(1, 2, 3); // โ
passes (enumerable values check)
new List<int> { 1, 2, 3, 4, 5, 6 }.Where(i => i % 2 == 0).Is(2, 4, 6); // โ
passes
new List<int> { 1, 2, 3, 4, 5, 6 }.Where(i => i % 3 == 0).Is(3, 6); // โ
passes
new List<int> { 1, 2, 3, 4, 5, 6 }.Where(i => i % 4 == 0).Is(4); // โ
passes
new List<int> { 1, 2, 3, 4 }.IsContaining(1, 2); // โ
passes
new List<int> { 1, 2 }.IsIn(1, 2, 3, 4); // โ
passes
Type checks
"hello".Is<string>(); // โ
passes
"hello".Is<int>(); // โ throws IsNotException: "hello" (System.String) is no System.Int32
Numeric comparisons
2.999999f.Is(3f) // โ
passes
783.0123.Is(783.0124) // โ
passes
5.IsSmallerThan(6); // โ
passes
6.IsGreaterThan(5.0); // โ
passes
5.IsGreaterThan(6); // โ throws IsNotException: 5 (System.Int32) is not greater than 6 (System.Int32)
2.IsBetween(1, 3); // โ
passes
0.3.Is(0.1 + 0.2); // โ
passes
0.3.IsExactly(0.1 + 0.2); // โ fails
0.3.IsApproximately(0.1 + 0.2); // โ
passes
0.333333.Is(1.0 / 3.0); // โ
passes
0.33333.Is(1.0 / 3.0); // โ throws IsNotException: 0,33333 (System.Double) is not close to 0,3333333333333333 (System.Double)
Exception assertions
static int DivideByZero(int value) => value / 0;
Action action = () => _ = DivideByZero(1);
action.IsThrowing<DivideByZeroException>(); // โ
passes
Action action = () => 5.IsGreaterThan(6);
action.IsThrowing<IsNotException>("is not greater than"); // โ
passes
String checks
var groups = "hello world".IsMatching("(.*) (.*)"); // โ
passes
groups[1].Value.Is("hello"); // โ
passes
groups[2].Value.Is("world"); // โ
passes
"hello world".IsContaining("hello"); // โ
passes
โ Error messages
Exception messages
- uses colors to highlight important parts
- displays the source of the error (line number and code)
โ๏ธ Design Philosophy
- โ No
.Should()
, no fluent bloat - โ All positive assertions (Is, IsNull, IsTrue, etc.)
- ๐ข Failure messages like:
42 (System.Int32) is not 41 (System.Int32)
- ๐ง Designed to make tests read like intentions, not machinery
๐ Key Advantages of Is
- ๐ง Ultra-Concise Syntax with Natural Readability
- ๐งต Minimal Dependencies / Fast Startup
- Lean and dependency-free โ ideal for CI pipelines or constrained environments.
- ๐งช Focused on Behavior, Not Chaining
- Prioritizes clarity over fluent DSL chaining.
- ๐ง Extensible and Easy to Maintain
- Simple to audit, fork, and adapt for your team or test infrastructure.
๐ License
MIT โ use freely.
๐ Contributing
Ideas, bug reports, or pull requests are always welcome.
โค๏ธ Author
Developed with care by chrismo80
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.10.1 | 138 | 7/9/2025 |
1.10.0 | 68 | 7/4/2025 |
1.9.1 | 134 | 6/30/2025 |
1.9.0 | 134 | 6/30/2025 |
1.8.1 | 69 | 6/28/2025 |
1.8.0 | 132 | 6/26/2025 |
1.7.3 | 138 | 6/25/2025 |
1.7.2 | 136 | 6/25/2025 |
1.7.1 | 135 | 6/25/2025 |
1.7.0 | 104 | 6/21/2025 |
1.6.0 | 144 | 6/19/2025 |
1.5.0 | 143 | 6/19/2025 |
1.4.0 | 134 | 6/18/2025 |
1.3.4 | 137 | 6/17/2025 |
1.3.3 | 135 | 6/16/2025 |
1.3.2 | 142 | 6/16/2025 |
1.3.1 | 201 | 6/8/2025 |
1.3.0 | 112 | 6/7/2025 |
1.2.0 | 139 | 6/5/2025 |
1.1.0 | 147 | 6/4/2025 |
1.0.0 | 145 | 6/2/2025 |