Skip to content

Instantly share code, notes, and snippets.

@adamralph
Created October 17, 2012 08:16
Show Gist options
  • Save adamralph/3904338 to your computer and use it in GitHub Desktop.
Save adamralph/3904338 to your computer and use it in GitHub Desktop.
xbehave background out param idea
[Background]
public static void Background(out Stack<int> stack)
{
"Given a stack"
.Given(() => stack = new Stack<int>());
}
[Scenario]
[Example(123)]
[Example(234)]
public static void Push(int element, Stack<int> stack)
{
"Given {0}"
.Given(() => new Disposable().Using());
"When pushing {0} onto the stack"
.When(() => stack.Push(element))
.Teardown(() => stack.Clear())
.And()
.WithTimeout(1000);
"Then the stack should not be empty"
.Then(() => stack.Should().NotBeEmpty());
"And the stack pop should be {0}"
.And(() => stack.Pop().Should().Be(element))
.InIsolation()
.And()
.WithTimeout(1000);
"And the stack peek should be {0}"
.And(() => stack.Peek().Should().Be(element))
.WithTimeout(1000);
"And the stack count should be 3"
.And(() => stack.Count().Should().Be(2))
.Skip("because the assertion is nonsense");
"But the stack count should not be 2"
.But(() => stack.Count().Should().NotBe(2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment