-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33631d5
commit 3c46893
Showing
7 changed files
with
264 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SpecFlow | ||
|
||
* Dependencies: NUnit | xUnit | MsTest | ||
* NuGet: https://www.nuget.org/packages/SpecFlow/ | ||
* Source: https://github.com/techtalk/SpecFlow |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Feature: Stack | ||
In order to support last-in-first-out (LIFO) operations | ||
As an developer | ||
I want to use a stack | ||
|
||
Scenario: Empty stack | ||
Given an empty stack | ||
Then it has no elements | ||
And it throws an exception when calling pop | ||
And it throws an exception when calling peek | ||
|
||
Scenario: Non empty stack | ||
Given a non empty stack | ||
When calling peek | ||
Then it returns the top element | ||
But it does not remove the top element | ||
When calling pop | ||
Then it returns the top element | ||
And it removes the top element |
139 changes: 139 additions & 0 deletions
139
BDD/ConductOfCode/ConductOfCode/SpecFlow/Stack.feature.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using TechTalk.SpecFlow; | ||
using Xunit; | ||
|
||
namespace ConductOfCode.SpecFlow | ||
{ | ||
[Binding] | ||
public class StackSteps | ||
{ | ||
private Stack<int> stack; | ||
|
||
private int result; | ||
|
||
// Empty | ||
|
||
[Given(@"an empty stack")] | ||
public void GivenAnEmptyStack() | ||
{ | ||
stack = new Stack<int>(); | ||
} | ||
|
||
[Then(@"it has no elements")] | ||
public void ThenItHasNoElements() | ||
{ | ||
Assert.Empty(stack); | ||
} | ||
|
||
[Then(@"it throws an exception when calling pop")] | ||
public void ThenItThrowsAnExceptionWhenCallingPop() | ||
{ | ||
Assert.Throws<InvalidOperationException>(() => stack.Pop()); | ||
} | ||
|
||
[Then(@"it throws an exception when calling peek")] | ||
public void ThenItThrowsAnExceptionWhenCallingPeek() | ||
{ | ||
Assert.Throws<InvalidOperationException>(() => stack.Peek()); | ||
} | ||
|
||
// Not empty | ||
|
||
[Given(@"a non empty stack")] | ||
public void GivenANonEmptyStack() | ||
{ | ||
stack = new Stack<int>(new[] { 1, 2, 3 }); | ||
} | ||
|
||
[When(@"calling peek")] | ||
public void WhenCallingPeek() | ||
{ | ||
result = stack.Peek(); | ||
} | ||
|
||
[Then(@"it returns the top element")] | ||
public void ThenItReturnsTheTopElement() | ||
{ | ||
Assert.Equal(3, result); | ||
} | ||
|
||
[Then(@"it does not remove the top element")] | ||
public void ThenItDoesNotRemoveTheTopElement() | ||
{ | ||
Assert.Contains(3, stack); | ||
} | ||
|
||
[When(@"calling pop")] | ||
public void WhenCallingPop() | ||
{ | ||
result = stack.Pop(); | ||
} | ||
|
||
[Then(@"it removes the top element")] | ||
public void ThenItRemovesTheTopElement() | ||
{ | ||
Assert.DoesNotContain(3, stack); | ||
} | ||
} | ||
} |
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
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