Skip to content

Commit a11c641

Browse files
committed
✨ Xbehave
1 parent 96057b2 commit a11c641

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@
9090
<Reference Include="System.Data" />
9191
<Reference Include="System.Net.Http" />
9292
<Reference Include="System.Xml" />
93+
<Reference Include="Xbehave.Core, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e4957f48888f9fe8, processorArchitecture=MSIL">
94+
<HintPath>..\packages\Xbehave.Core.2.1.0\lib\portable-net45\Xbehave.Core.dll</HintPath>
95+
<Private>True</Private>
96+
</Reference>
97+
<Reference Include="Xbehave.Execution.desktop, Version=2.1.0.0, Culture=neutral, PublicKeyToken=e4957f48888f9fe8, processorArchitecture=MSIL">
98+
<HintPath>..\packages\Xbehave.Core.2.1.0\lib\portable-net45\Xbehave.Execution.desktop.dll</HintPath>
99+
<Private>True</Private>
100+
</Reference>
101+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
102+
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
103+
<Private>True</Private>
104+
</Reference>
105+
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
106+
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
107+
<Private>True</Private>
108+
</Reference>
109+
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
110+
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
111+
<Private>True</Private>
112+
</Reference>
113+
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
114+
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
115+
<Private>True</Private>
116+
</Reference>
93117
</ItemGroup>
94118
<ItemGroup>
95119
<Compile Include="DebuggerShim.cs" />
@@ -101,6 +125,7 @@
101125
<Compile Include="NSpec\stack_specs.cs" />
102126
<Compile Include="Properties\AssemblyInfo.cs" />
103127
<Compile Include="SpecsFor\StackSpecs.cs" />
128+
<Compile Include="Xbehave\StackFeature.cs" />
104129
</ItemGroup>
105130
<ItemGroup>
106131
<None Include="app.config" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# xBehave
2+
3+
* Dependencies: xUnit
4+
* NuGet: https://www.nuget.org/packages/Xbehave/
5+
* Source: https://github.com/xbehave/xbehave.net
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Xbehave;
4+
using Xunit;
5+
6+
namespace ConductOfCode.Xbehave
7+
{
8+
public class StackFeature
9+
{
10+
[Scenario]
11+
public void Empty(Stack<int> stack)
12+
{
13+
"Given an empty stack"
14+
.x(() => stack = new Stack<int>());
15+
16+
"Then it has no elements"
17+
.x(() => Assert.Empty(stack));
18+
19+
"And it throws an exception when calling pop"
20+
.x(() => Assert.Throws<InvalidOperationException>(() => stack.Pop()));
21+
22+
"And it throws an exception when calling peek"
23+
.x(() => Assert.Throws<InvalidOperationException>(() => stack.Peek()));
24+
}
25+
26+
[Scenario]
27+
public void NotEmpty(Stack<int> stack, int result)
28+
{
29+
"Given a non empty stack"
30+
.x(() => stack = new Stack<int>(new[] { 1, 2, 3 }));
31+
32+
"When calling peek"
33+
.x(() => result = stack.Peek());
34+
35+
"Then it returns the top element"
36+
.x(() => Assert.Equal(3, result));
37+
38+
"But it does not remove the top element"
39+
.x(() => Assert.Contains(3, stack));
40+
41+
"When calling pop"
42+
.x(() => result = stack.Pop());
43+
44+
"The it returns the top element"
45+
.x(() => Assert.Equal(3, result));
46+
47+
"And it removes the top element"
48+
.x(() => Assert.DoesNotContain(3, stack));
49+
}
50+
}
51+
}

BDD/ConductOfCode/ConductOfCode/packages.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@
1212
<package id="Should" version="1.1.20" targetFramework="net46" />
1313
<package id="SpecsFor" version="5.0.0" targetFramework="net46" />
1414
<package id="structuremap" version="4.1.3.394" targetFramework="net46" />
15+
<package id="Xbehave" version="2.1.0" targetFramework="net46" />
16+
<package id="Xbehave.Core" version="2.1.0" targetFramework="net46" />
17+
<package id="xunit" version="2.1.0" targetFramework="net46" />
18+
<package id="xunit.abstractions" version="2.0.0" targetFramework="net46" />
19+
<package id="xunit.assert" version="2.1.0" targetFramework="net46" />
20+
<package id="xunit.core" version="2.1.0" targetFramework="net46" />
21+
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net46" />
22+
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net46" />
1523
</packages>

0 commit comments

Comments
 (0)