Skip to content

Commit

Permalink
✨ MSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
hlaueriksson committed Jul 30, 2016
1 parent 513f0fc commit 217e02c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
13 changes: 13 additions & 0 deletions BDD/ConductOfCode/ConductOfCode/ConductOfCode.csproj
Expand Up @@ -38,6 +38,18 @@
<HintPath>..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.dll</HintPath> <HintPath>..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Machine.Specifications, Version=0.9.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Machine.Specifications.Clr4, Version=0.9.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.Clr4.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Machine.Specifications.Should, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Machine.Specifications.Should.0.9.0\lib\net45\Machine.Specifications.Should.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Private>True</Private> <Private>True</Private>
Expand All @@ -56,6 +68,7 @@
<Compile Include="LightBDD\Stack_feature.Steps.cs"> <Compile Include="LightBDD\Stack_feature.Steps.cs">
<DependentUpon>Stack_feature.cs</DependentUpon> <DependentUpon>Stack_feature.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="MSpec\StackSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions BDD/ConductOfCode/ConductOfCode/MSpec/README.md
@@ -0,0 +1,5 @@
# Machine.Specifications (MSpec)

* Dependencies: -
* NuGet: https://www.nuget.org/packages/Machine.Specifications/
* Source: https://github.com/machine/machine.specifications
49 changes: 49 additions & 0 deletions BDD/ConductOfCode/ConductOfCode/MSpec/StackSpecs.cs
@@ -0,0 +1,49 @@
using System;
using Machine.Specifications;

namespace ConductOfCode.MSpec
{
using System.Collections.Generic;

public class StackSpecs
{
[Subject(typeof(Stack<>))]
public class When_empty
{
Establish context = () =>
{
Subject = new Stack<int>();
};

It should_have_no_elements = () => Subject.ShouldBeEmpty();
It should_throw_an_exception_when_calling_pop = () => Catch.Exception(() => Subject.Pop()).ShouldBeOfExactType<InvalidOperationException>();
It should_throw_an_exception_when_calling_peek = () => Catch.Exception(() => Subject.Peek()).ShouldBeOfExactType<InvalidOperationException>();

static Stack<int> Subject;
}

[Subject(typeof(Stack<>))]
public class When_not_empty
{
Establish context = () =>
{
Subject = new Stack<int>(new[] { 1, 2, 3 });
};

It should_return_the_top_element_when_calling_peek = () => Subject.Peek().ShouldEqual(3);
It should_not_remove_the_top_element_when_calling_peek = () =>
{
Subject.Peek();
Subject.ShouldContain(3);
};
It should_return_the_top_element_when_calling_pop = () => Subject.Pop().ShouldEqual(3);
It should_remove_the_top_element_when_calling_pop = () =>
{
Subject.Pop();
Subject.ShouldNotContain(3);
};

static Stack<int> Subject;
}
}
}
2 changes: 2 additions & 0 deletions BDD/ConductOfCode/ConductOfCode/packages.config
Expand Up @@ -3,5 +3,7 @@
<package id="LightBDD" version="1.7.1.0" targetFramework="net46" /> <package id="LightBDD" version="1.7.1.0" targetFramework="net46" />
<package id="LightBDD.Core" version="1.7.1.0" targetFramework="net46" /> <package id="LightBDD.Core" version="1.7.1.0" targetFramework="net46" />
<package id="LightBDD.NUnit" version="1.7.1.0" targetFramework="net46" /> <package id="LightBDD.NUnit" version="1.7.1.0" targetFramework="net46" />
<package id="Machine.Specifications" version="0.9.3" targetFramework="net46" />
<package id="Machine.Specifications.Should" version="0.9.0" targetFramework="net46" />
<package id="NUnit" version="2.6.3" targetFramework="net46" /> <package id="NUnit" version="2.6.3" targetFramework="net46" />
</packages> </packages>

0 comments on commit 217e02c

Please sign in to comment.