Last active
August 29, 2015 13:59
-
-
Save JakeGinnivan/10862720 to your computer and use it in GitHub Desktop.
BDDfy Additional Test
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
| using ApprovalTests; | |
| using NUnit.Framework; | |
| using Shouldly; | |
| using TestStack.BDDfy.Reporters; | |
| namespace TestStack.BDDfy.Tests.Scanner.FluentScanner | |
| { | |
| [TestFixture] | |
| public class FluentWithExamples | |
| { | |
| [Test] | |
| public void FluentCanBeUsedWithExamples() | |
| { | |
| var story = this | |
| .Given(_ => GivenMethodTaking__ExampleInt__(Prop1), false) | |
| .And(_ => GivenMethodTaking__Prop1__(_.Prop1)) | |
| .And(_ => GivenADifferentMethodWithRandomArg(2)) | |
| .And(_ => GivenADifferentMethodWith(Prop2)) | |
| .When(_ => WhenMethodUsing__ExampleString__()) | |
| .Then(_ => ThenAllIsGood()) | |
| .WithExamples(new ExampleTable("Prop 1", "Prop2", "Prop 3") | |
| { | |
| {1, "foo", ExecutionOrder.ConsecutiveAssertion }, | |
| {2, "bar", ExecutionOrder.Initialize } | |
| }) | |
| .BDDfy(); | |
| var textReporter = new TextReporter(); | |
| textReporter.Process(story); | |
| Approvals.Verify(textReporter.ToString()); | |
| } | |
| private void GivenADifferentMethodWith(string prop2) | |
| { | |
| Prop2.ShouldBeOneOf("foo", "bar"); | |
| } | |
| private void GivenADifferentMethodWithRandomArg(int foo) | |
| { | |
| } | |
| private void ThenAllIsGood() | |
| { | |
| } | |
| private void WhenMethodUsing__ExampleString__() | |
| { | |
| Prop2.ShouldBeOneOf("foo", "bar"); | |
| Prop3.ShouldBeOneOf(ExecutionOrder.ConsecutiveAssertion, ExecutionOrder.Initialize); | |
| } | |
| private void GivenMethodTaking__ExampleInt__(int exampleInt) | |
| { | |
| exampleInt.ShouldBeInRange(1, 2); | |
| } | |
| private void GivenMethodTaking__Prop1__(int exampleInt) | |
| { | |
| exampleInt.ShouldBeInRange(1, 2); | |
| } | |
| public int Prop1 { get; set; } | |
| public string Prop2 { get; set; } | |
| public ExecutionOrder Prop3 { get; set; } | |
| } | |
| } |
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
| Scenario: Fluent can be used with examples | |
| Given method taking <example int> | |
| Given method taking <prop 1> | |
| Given a different method with random arg 2 | |
| Given a different method with <prop 2> | |
| When method using <example string> | |
| Then all is good | |
| Examples: | |
| | Prop 1 | Prop2 | Prop 3 | | |
| | 1 | foo | ConsecutiveAssertion | | |
| | 2 | bar | Initialize | | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment