Skip to content
Permalink
Browse files

MSpec

  • Loading branch information
hlaueriksson committed Jul 30, 2016
1 parent 513f0fc commit 217e02c329bb8590e3aade6f5d0ff44d1ba14e6e
@@ -38,6 +38,18 @@
<HintPath>..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.dll</HintPath>
<Private>True</Private>
</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">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
@@ -56,6 +68,7 @@
<Compile Include="LightBDD\Stack_feature.Steps.cs">
<DependentUpon>Stack_feature.cs</DependentUpon>
</Compile>
<Compile Include="MSpec\StackSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,5 @@
# Machine.Specifications (MSpec)

* Dependencies: -
* NuGet: https://www.nuget.org/packages/Machine.Specifications/
* Source: https://github.com/machine/machine.specifications
@@ -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;
}
}
}
@@ -3,5 +3,7 @@
<package id="LightBDD" 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="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" />
</packages>

0 comments on commit 217e02c

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