Skip to content
Permalink
Browse files

SpecFlow

  • Loading branch information
hlaueriksson committed Jul 30, 2016
1 parent 33631d5 commit 3c468931d7eb71e0fff2840200a25f67f5a0d273
@@ -218,6 +218,10 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TechTalk.SpecFlow, Version=2.1.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41, processorArchitecture=MSIL">
<HintPath>..\packages\SpecFlow.2.1.0\lib\net45\TechTalk.SpecFlow.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xbehave.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e4957f48888f9fe8, processorArchitecture=MSIL">
<HintPath>..\packages\Xbehave.Core.2.1.0\lib\portable-net45\Xbehave.Core.dll</HintPath>
<Private>True</Private>
@@ -257,12 +261,22 @@
<Compile Include="MSpec\StackSpecs.cs" />
<Compile Include="NSpec\stack_specs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpecFlow\Stack.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Stack.feature</DependentUpon>
</Compile>
<Compile Include="SpecFlow\StackSteps.cs" />
<Compile Include="SpecsFor\StackSpecs.cs" />
<Compile Include="Xbehave\StackFeature.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="SpecFlow\Stack.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Stack.feature.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Concordion\Stack.html" />
@@ -0,0 +1,5 @@
# SpecFlow

* Dependencies: NUnit | xUnit | MsTest
* NuGet: https://www.nuget.org/packages/SpecFlow/
* Source: https://github.com/techtalk/SpecFlow
@@ -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

Some generated files are not rendered by default. Learn more.

@@ -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);
}
}
}
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -8,4 +11,6 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<specFlow>
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><unitTestProvider name="xUnit" /></specFlow></configuration>
@@ -12,6 +12,8 @@
<package id="nspec" version="1.0.7" targetFramework="net46" />
<package id="NUnit" version="2.6.4" targetFramework="net46" />
<package id="Should" version="1.1.20" targetFramework="net46" />
<package id="SpecFlow" version="2.1.0" targetFramework="net46" />
<package id="SpecFlow.xUnit" version="2.1.0" targetFramework="net46" />
<package id="SpecsFor" version="5.0.0" targetFramework="net46" />
<package id="structuremap" version="4.1.3.394" targetFramework="net46" />
<package id="Xbehave" version="2.1.0" targetFramework="net46" />

0 comments on commit 3c46893

Please sign in to comment.
You can’t perform that action at this time.