-
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
96057b2
commit a11c641
Showing
4 changed files
with
89 additions
and
0 deletions.
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 @@ | ||
# xBehave | ||
|
||
* Dependencies: xUnit | ||
* NuGet: https://www.nuget.org/packages/Xbehave/ | ||
* Source: https://github.com/xbehave/xbehave.net |
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,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Xbehave; | ||
using Xunit; | ||
|
||
namespace ConductOfCode.Xbehave | ||
{ | ||
public class StackFeature | ||
{ | ||
[Scenario] | ||
public void Empty(Stack<int> stack) | ||
{ | ||
"Given an empty stack" | ||
.x(() => stack = new Stack<int>()); | ||
|
||
"Then it has no elements" | ||
.x(() => Assert.Empty(stack)); | ||
|
||
"And it throws an exception when calling pop" | ||
.x(() => Assert.Throws<InvalidOperationException>(() => stack.Pop())); | ||
|
||
"And it throws an exception when calling peek" | ||
.x(() => Assert.Throws<InvalidOperationException>(() => stack.Peek())); | ||
} | ||
|
||
[Scenario] | ||
public void NotEmpty(Stack<int> stack, int result) | ||
{ | ||
"Given a non empty stack" | ||
.x(() => stack = new Stack<int>(new[] { 1, 2, 3 })); | ||
|
||
"When calling peek" | ||
.x(() => result = stack.Peek()); | ||
|
||
"Then it returns the top element" | ||
.x(() => Assert.Equal(3, result)); | ||
|
||
"But it does not remove the top element" | ||
.x(() => Assert.Contains(3, stack)); | ||
|
||
"When calling pop" | ||
.x(() => result = stack.Pop()); | ||
|
||
"The it returns the top element" | ||
.x(() => Assert.Equal(3, result)); | ||
|
||
"And it removes the top element" | ||
.x(() => 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