-
-
Save adamralph/3923217 to your computer and use it in GitHub Desktop.
Behaviors with LINQ syntax using a scenario monad
This file contains hidden or 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 IntervalFeature : Feature | |
{ | |
[Scenario] | |
public void Comparison() | |
{ | |
var result = | |
from interval in Given("an interval", Interval.WholeStep) | |
from smallerInterval in And("a smaller interval", Interval.HalfStep) | |
select When("comparing the intervals", left.CompareTo(right)); | |
Then("the first interval is determined to be larger than the second interval", () => result.Should().Be(1)); | |
} | |
} |
This file contains hidden or 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 IntervalFeature | |
{ | |
[Scenario] | |
public void ComparisonUsingLinq() | |
{ | |
var result = | |
from left in "Given an interval".Of(Interval.WholeStep) | |
from right in "And a smaller interval".Of(Interval.HalfStep) | |
select "When comparing the intervals".Do(left.CompareTo(right)); | |
"Then the first interval is determined to be larger than the second interval".Do(() => result.Should().Be(1)); | |
} | |
[Scenario] | |
public void ComparisonWithoutUsingLinq() | |
{ | |
var left = "Given an interval".Given(() => Interval.WholeStep); | |
var right = "And a smaller interval".And(() => Interval.HalfStep); | |
var result = "When comparing the intervals".When(() => left.CompareTo(right)); | |
"Then the first interval is determined to be larger than the second interval".Then(() => result.Should().Be(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment