-
Notifications
You must be signed in to change notification settings - Fork 53
Welcome to the NFluent wiki
Cyrille DUPUYDAUBY edited this page Feb 2, 2018
·
6 revisions
NFluent is an assertion library. It helps developers write and maintain their automated unit tests.
- Understanding unit testing/TDD/BDD (you can try NUnit website if you want to know more on those topics)
- Simply add NFluent to your test project(s) with Nuget (search for NFluent)
- Nothing else. NFluent is compatible with all testing frameworks (NUnit, xUnit, MSTest,...)
It is that simple:
using NFluent;
...
// [Fact] with xUnit
// [TestMethod] with MsTest
[Test] // Using NUnit
public void CalculatorShouldAddCorrectly()
{
var myCalculator = new Calculator();
// this lines verifies that the Add method returns the expected
// result when adding 2 and 5.
Check.That(myCalculator.Add(2, 5) ).IsEqualTo(7);
// NUnit equivalent Assert.AreEqual(7, myCalculator.Add(2,5)
}
- Clearly expressed checks: NFluent assertions can be read (almost) as a sentence. Previous example is: check that mycalculator(2, 5) result is equal to 7. This is way better than: assert that are equal 7 and mycalculator(2, 5) result, unless you are Yoda and you prefer your verb in front
- Helpful error messages: NFluent provides explicit and guiding messages when an assertion fails. Specifically, it provides a sentence explaining precisely why the test failed as well as information regarding the observed result as well as the expected one.
- Auto-completion driven: modern IDEs provide performant autocompletion logic. NFluent leverages those so you do not have to browse the documention to discover what you can do.
- Decoupling: using an assertion framework will reduce the amount of effort needed if you want/have to migrate to another testing framewok.
- Welcome
- How to start
- Customising error messages
-
Check.That
- All (Equality, Type)
- Reference types
- Members based
- IEnumerable (Properties, Content, Elements)
- String (Properties, Content, RegExp )
- Numeric Type(Properties, Comparisons, Floating)
- Dictionary
- Char (Properties, Value)
- IComparable
- DateTime
- DateTimeOffset
- Misc: Boolean, TimeSpan, Stream, Enum, EventWaitHandle
- Check.ThatCode
- Check.ThatDynamic
- Extensibility
- Auxiliary types (TimeUnit)
- Mocks