Skip to content

Commit 96057b2

Browse files
committed
✨ SpecsFor
1 parent dc8a8b5 commit 96057b2

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
3232
<ItemGroup>
33+
<Reference Include="ExpectedObjects, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">
34+
<HintPath>..\packages\ExpectedObjects.1.2.3\lib\net40\ExpectedObjects.dll</HintPath>
35+
<Private>True</Private>
36+
</Reference>
3337
<Reference Include="LightBDD, Version=1.7.1.0, Culture=neutral, processorArchitecture=MSIL">
3438
<HintPath>..\packages\LightBDD.Core.1.7.1.0\lib\net40\LightBDD.dll</HintPath>
3539
<Private>True</Private>
@@ -50,6 +54,10 @@
5054
<HintPath>..\packages\Machine.Specifications.Should.0.9.0\lib\net45\Machine.Specifications.Should.dll</HintPath>
5155
<Private>True</Private>
5256
</Reference>
57+
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
58+
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
59+
<Private>True</Private>
60+
</Reference>
5361
<Reference Include="NSpec, Version=1.0.7.0, Culture=neutral, processorArchitecture=MSIL">
5462
<HintPath>..\packages\nspec.1.0.7\lib\NSpec.dll</HintPath>
5563
<Private>True</Private>
@@ -58,6 +66,22 @@
5866
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
5967
<Private>True</Private>
6068
</Reference>
69+
<Reference Include="Should, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\packages\Should.1.1.20\lib\Should.dll</HintPath>
71+
<Private>True</Private>
72+
</Reference>
73+
<Reference Include="SpecsFor, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
74+
<HintPath>..\packages\SpecsFor.5.0.0\lib\net40\SpecsFor.dll</HintPath>
75+
<Private>True</Private>
76+
</Reference>
77+
<Reference Include="StructureMap, Version=4.1.3.394, Culture=neutral, processorArchitecture=MSIL">
78+
<HintPath>..\packages\structuremap.4.1.3.394\lib\net40\StructureMap.dll</HintPath>
79+
<Private>True</Private>
80+
</Reference>
81+
<Reference Include="StructureMap.Net4, Version=4.1.3.394, Culture=neutral, processorArchitecture=MSIL">
82+
<HintPath>..\packages\structuremap.4.1.3.394\lib\net40\StructureMap.Net4.dll</HintPath>
83+
<Private>True</Private>
84+
</Reference>
6185
<Reference Include="System" />
6286
<Reference Include="System.Core" />
6387
<Reference Include="System.Xml.Linq" />
@@ -76,6 +100,7 @@
76100
<Compile Include="MSpec\StackSpecs.cs" />
77101
<Compile Include="NSpec\stack_specs.cs" />
78102
<Compile Include="Properties\AssemblyInfo.cs" />
103+
<Compile Include="SpecsFor\StackSpecs.cs" />
79104
</ItemGroup>
80105
<ItemGroup>
81106
<None Include="app.config" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SpecsFor
2+
3+
* Dependencies: NUnit
4+
* NuGet: https://www.nuget.org/packages/SpecsFor/
5+
* Source: https://github.com/MattHoneycutt/SpecsFor
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using NUnit.Framework;
4+
using Should;
5+
using SpecsFor;
6+
7+
namespace ConductOfCode.SpecsFor
8+
{
9+
public class StackSpecs
10+
{
11+
public class given_an_empty_stack : SpecsFor<Stack<int>>
12+
{
13+
[Test]
14+
public void then_it_has_no_elements()
15+
{
16+
SUT.Count.ShouldEqual(0);
17+
}
18+
19+
[Test]
20+
[ExpectedException(typeof(InvalidOperationException))]
21+
public void then_it_throws_an_exception_when_calling_pop()
22+
{
23+
SUT.Pop();
24+
}
25+
26+
[Test]
27+
[ExpectedException(typeof(InvalidOperationException))]
28+
public void then_it_throws_an_exception_when_calling_peek()
29+
{
30+
SUT.Peek();
31+
}
32+
}
33+
34+
public class given_a_non_empty_stack : SpecsFor<Stack<int>>
35+
{
36+
protected override void BeforeEachTest()
37+
{
38+
SUT = new Stack<int>(new[] { 1, 2, 3 });
39+
}
40+
41+
[Test]
42+
public void then_it_returns_the_top_element_when_calling_peek()
43+
{
44+
SUT.Peek().ShouldEqual(3);
45+
}
46+
47+
[Test]
48+
public void then_it_does_not_remove_the_top_element_when_calling_peek()
49+
{
50+
SUT.Peek();
51+
SUT.ShouldContain(3);
52+
}
53+
54+
[Test]
55+
public void then_it_returns_the_top_element_when_calling_pop()
56+
{
57+
SUT.Pop().ShouldEqual(3);
58+
}
59+
60+
[Test]
61+
public void then_it_removes_the_top_element_when_calling_pop()
62+
{
63+
SUT.Pop();
64+
SUT.ShouldNotContain(3);
65+
}
66+
}
67+
}
68+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="ExpectedObjects" version="1.2.3" targetFramework="net46" />
34
<package id="LightBDD" version="1.7.1.0" targetFramework="net46" />
45
<package id="LightBDD.Core" version="1.7.1.0" targetFramework="net46" />
56
<package id="LightBDD.NUnit" version="1.7.1.0" targetFramework="net46" />
67
<package id="Machine.Specifications" version="0.9.3" targetFramework="net46" />
78
<package id="Machine.Specifications.Should" version="0.9.0" targetFramework="net46" />
9+
<package id="Moq" version="4.2.1510.2205" targetFramework="net46" />
810
<package id="nspec" version="1.0.7" targetFramework="net46" />
911
<package id="NUnit" version="2.6.3" targetFramework="net46" />
12+
<package id="Should" version="1.1.20" targetFramework="net46" />
13+
<package id="SpecsFor" version="5.0.0" targetFramework="net46" />
14+
<package id="structuremap" version="4.1.3.394" targetFramework="net46" />
1015
</packages>

0 commit comments

Comments
 (0)