Created
October 19, 2012 00:33
-
-
Save bwatts/3915594 to your computer and use it in GitHub Desktop.
Behaviors with LINQ syntax using a scenario monad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntervalComparisons : Behavior | |
{ | |
[Scenario] | |
public void GreaterThan() | |
{ | |
var result = | |
from left in Given("an interval", Interval.WholeStep) | |
from right in And("a lesser interval", Interval.HalfStep) | |
select When("comparing them", left.CompareTo(right)); | |
Then("the result is 1", () => result.Should().Be(1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntervalComparisons | |
{ | |
[Scenario] | |
public void Linq_NoBaseClass() | |
{ | |
var result = | |
from left in "Given an interval".Of(Interval.WholeStep) | |
from right in "And a lesser interval".Of(Interval.HalfStep) | |
select "When comparing them".Do(left.CompareTo(right)); | |
"Then the result is 1".Do(() => result.Should().Be(1)); | |
} | |
[Scenario] | |
public void NoLinq_InlineAssignments() | |
{ | |
var left = "Given an interval".Given(() => Interval.WholeStep); | |
var right = "And a lesser interval".And(() => Interval.HalfStep); | |
var result = "When comparing them".When(() => left.CompareTo(right)); | |
"Then the result is 1".Then(() => result.Should().Be(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment