Skip to content
Permalink
Browse files

LightBDD

  • Loading branch information
hlaueriksson committed Jul 30, 2016
1 parent 8ffed16 commit 513f0fce52ce63073fe662f9a1279b879399d99d
@@ -30,6 +30,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="LightBDD, Version=1.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LightBDD.Core.1.7.1.0\lib\net40\LightBDD.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="LightBDD.NUnit, Version=1.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LightBDD.NUnit.1.7.1.0\lib\net40\LightBDD.NUnit.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>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -40,8 +52,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LightBDD\Stack_feature.cs" />
<Compile Include="LightBDD\Stack_feature.Steps.cs">
<DependentUpon>Stack_feature.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -0,0 +1,5 @@
# LightBDD

* Dependencies: NUnit | MbUnit | MsTest | xUnit
* NuGet: https://www.nuget.org/packages/LightBDD/
* Source: https://github.com/Suremaker/LightBDD
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using LightBDD;
using NUnit.Framework;

namespace ConductOfCode.LightBDD
{
public partial class Stack_feature : FeatureFixture
{
private Stack<int> stack;

private int result;

// Empty

private void an_empty_stack()
{
stack = new Stack<int>();
}

private void it_has_no_elements()
{
Assert.That(stack, Is.Empty);
}

private void it_throws_an_exception_when_calling_pop()
{
Assert.Throws<InvalidOperationException>(() => stack.Pop());
}

private void it_throws_an_exception_when_calling_peek()
{
Assert.Throws<InvalidOperationException>(() => stack.Peek());
}

// Not empty

private void a_non_empty_stack()
{
stack = new Stack<int>(new[] { 1, 2, 3 });
}

private void calling_peek()
{
result = stack.Peek();
}

private void it_returns_the_top_element()
{
Assert.That(result, Is.EqualTo(3));
}

private void it_does_not_remove_the_top_element()
{
Assert.That(stack.Contains(3), Is.True);
}

private void calling_pop()
{
result = stack.Pop();
}

private void it_removes_the_top_element()
{
Assert.That(stack.Contains(result), Is.False);
}
}
}
@@ -0,0 +1,41 @@
using LightBDD;
using NUnit.Framework;

namespace ConductOfCode.LightBDD
{
[TestFixture]
[FeatureDescription(
@"In order to support last-in-first-out (LIFO) operations
As an developer
I want to use a stack")]
[Label("LIFO")]
public partial class Stack_feature
{
[Test]
[Label("Empty")]
public void Empty_stack()
{
Runner.RunScenario(

given => an_empty_stack(),
then => it_has_no_elements(),
and => it_throws_an_exception_when_calling_pop(),
and => it_throws_an_exception_when_calling_peek());
}

[Test]
[Label("Not empty")]
public void Non_empty_stack()
{
Runner.RunScenario(

given => a_non_empty_stack(),
when => calling_peek(),
then => it_returns_the_top_element(),
but => it_does_not_remove_the_top_element(),
when => calling_pop(),
then => it_returns_the_top_element(),
and => it_removes_the_top_element());
}
}
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<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="NUnit" version="2.6.3" targetFramework="net46" />
</packages>

0 comments on commit 513f0fc

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