Skip to content

Commit 217e02c

Browse files
committed
✨ MSpec
1 parent 513f0fc commit 217e02c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
<HintPath>..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.dll</HintPath>
3939
<Private>True</Private>
4040
</Reference>
41+
<Reference Include="Machine.Specifications, Version=0.9.3.0, Culture=neutral, processorArchitecture=MSIL">
42+
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.dll</HintPath>
43+
<Private>True</Private>
44+
</Reference>
45+
<Reference Include="Machine.Specifications.Clr4, Version=0.9.3.0, Culture=neutral, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.Clr4.dll</HintPath>
47+
<Private>True</Private>
48+
</Reference>
49+
<Reference Include="Machine.Specifications.Should, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
50+
<HintPath>..\packages\Machine.Specifications.Should.0.9.0\lib\net45\Machine.Specifications.Should.dll</HintPath>
51+
<Private>True</Private>
52+
</Reference>
4153
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
4254
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
4355
<Private>True</Private>
@@ -56,6 +68,7 @@
5668
<Compile Include="LightBDD\Stack_feature.Steps.cs">
5769
<DependentUpon>Stack_feature.cs</DependentUpon>
5870
</Compile>
71+
<Compile Include="MSpec\StackSpecs.cs" />
5972
<Compile Include="Properties\AssemblyInfo.cs" />
6073
</ItemGroup>
6174
<ItemGroup>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Machine.Specifications (MSpec)
2+
3+
* Dependencies: -
4+
* NuGet: https://www.nuget.org/packages/Machine.Specifications/
5+
* Source: https://github.com/machine/machine.specifications
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using Machine.Specifications;
3+
4+
namespace ConductOfCode.MSpec
5+
{
6+
using System.Collections.Generic;
7+
8+
public class StackSpecs
9+
{
10+
[Subject(typeof(Stack<>))]
11+
public class When_empty
12+
{
13+
Establish context = () =>
14+
{
15+
Subject = new Stack<int>();
16+
};
17+
18+
It should_have_no_elements = () => Subject.ShouldBeEmpty();
19+
It should_throw_an_exception_when_calling_pop = () => Catch.Exception(() => Subject.Pop()).ShouldBeOfExactType<InvalidOperationException>();
20+
It should_throw_an_exception_when_calling_peek = () => Catch.Exception(() => Subject.Peek()).ShouldBeOfExactType<InvalidOperationException>();
21+
22+
static Stack<int> Subject;
23+
}
24+
25+
[Subject(typeof(Stack<>))]
26+
public class When_not_empty
27+
{
28+
Establish context = () =>
29+
{
30+
Subject = new Stack<int>(new[] { 1, 2, 3 });
31+
};
32+
33+
It should_return_the_top_element_when_calling_peek = () => Subject.Peek().ShouldEqual(3);
34+
It should_not_remove_the_top_element_when_calling_peek = () =>
35+
{
36+
Subject.Peek();
37+
Subject.ShouldContain(3);
38+
};
39+
It should_return_the_top_element_when_calling_pop = () => Subject.Pop().ShouldEqual(3);
40+
It should_remove_the_top_element_when_calling_pop = () =>
41+
{
42+
Subject.Pop();
43+
Subject.ShouldNotContain(3);
44+
};
45+
46+
static Stack<int> Subject;
47+
}
48+
}
49+
}

BDD/ConductOfCode/ConductOfCode/packages.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
<package id="LightBDD" version="1.7.1.0" targetFramework="net46" />
44
<package id="LightBDD.Core" version="1.7.1.0" targetFramework="net46" />
55
<package id="LightBDD.NUnit" version="1.7.1.0" targetFramework="net46" />
6+
<package id="Machine.Specifications" version="0.9.3" targetFramework="net46" />
7+
<package id="Machine.Specifications.Should" version="0.9.0" targetFramework="net46" />
68
<package id="NUnit" version="2.6.3" targetFramework="net46" />
79
</packages>

0 commit comments

Comments
 (0)