NUnit
Constraint model of assertions. The logic necessary to carry out each assertion is embedded in the constraint object passed as the second parameter to that method.
- Constraint model
- Constraints by category
- Install
- Visual Studio Test Generator
- Visual Studio Test Adapter
| NUnit | Assert.That |
|---|---|
| object type and properties | Is.TypeOf<T>(), Is.InstanceOf<T>(), Has.Property("PropertyName") |
| exceptions | Throws.Exception Throws.TypeOf<TException>() .With.Matches |
| strings | Is.EqualTo(“expected”) Is.EqualTo("eXpeCTed").IgnoreCase Is.Not.EqualTo(“notExpected”) |
| Numerical values | Is.EqualTo(int) Is.EqualTo(float).Within(tolerance) Is.EqualTo(val).Within(p).Percent Is.Positive / Is.Negative / Is.NaN |
| DateTime | Is.EqualTo(dt).Within(ts) Is.EqualTo(dt).Within(v).Milliseconds |
| Ranges | Is.GreaterThan(v) / Is.LessThan(v) Is.GreaterThanOrEqualTo(v) Is.InRange(lo,hi) |
| Collections | Is.All.Empty Contains.Item(item) Has.Some.ContainsSubstring(“sub_str”) Has.Exactly(m).EndsWith(“suffix”) Is.Unique Has.None.EqualTo(val) Is.EquivalentTo(actualCollection) Is.Ordered |
| References | Is.SameAs Is.Not.SameAs |
| Nulls & booleans | Is.Not.Empty, Is.Null, Is.True |