https://github.com/tkellogg/natural.nunit
BDD using NUnit like an RSpec user would expect
https://github.com/tkellogg/natural.nunit
Last synced: about 1 year ago
JSON representation
BDD using NUnit like an RSpec user would expect
- Host: GitHub
- URL: https://github.com/tkellogg/natural.nunit
- Owner: tkellogg
- Created: 2011-12-19T15:34:33.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2018-07-07T00:02:57.000Z (almost 8 years ago)
- Last Synced: 2025-01-28T09:44:57.964Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 3.62 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
This project is an exploration into using assertion expressions that feel much
more natural to a C# developer. Instead of jumping on the "fluent" API bandwagon,
Natural NUnit makes heavy use of overloaded operators to use the expressiveness
of core C#.
Theory
=====================
Frameworks like [Rspec](http://rspec.info/) and [Jasmine](https://jasmine.github.io/)
are perfectly suited to the BDD design pattern, mostly because the
languages they're implemented in (Ruby & JavaScript) have certain features
that make them easy to implement BDD. C# has some features in common
with Ruby & JS, but current implementations [imo] don't make effective
usage of existing C# features and, as a result, they look ugly.
Quick Start
=====================
Use operator overloads for better assertions
```csharp
int result = CalculateRating();
// uses operator overloads instead of awkward fluent methods
Assert.That(result.Should() == 5);
// The == operator can also be an alias for Assert.That(actual, Is.EquivalentTo(expected))
var expected = new List{ 5 };
var actual = new[]{ result };
Assert.That(actual.Should() == expected);
// it uses boolean operators to combine assertions
Assert.That(result.Should() > 3 && result.Should() < 6);
// it allows you to use parentheses for clarity. Use the !operator to negate expressions
Assert.That(result.Should() > 3 && !(result.Should() < 6 || result.Should() > 60));
// Not yet implemented
// it allows you to use clearer, more mathematical range specs
Assert.That(3 < result.Should() < 6);
```
Please fork & contribute!