Skip to content
Permalink
Browse files

NSpec

  • Loading branch information
hlaueriksson committed Jul 30, 2016
1 parent 217e02c commit dc8a8b5f65128a3a95920911cb0af60fdfd7c3a1
@@ -50,6 +50,10 @@
<HintPath>..\packages\Machine.Specifications.Should.0.9.0\lib\net45\Machine.Specifications.Should.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NSpec, Version=1.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\nspec.1.0.7\lib\NSpec.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>
@@ -64,14 +68,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DebuggerShim.cs" />
<Compile Include="LightBDD\Stack_feature.cs" />
<Compile Include="LightBDD\Stack_feature.Steps.cs">
<DependentUpon>Stack_feature.cs</DependentUpon>
</Compile>
<Compile Include="MSpec\StackSpecs.cs" />
<Compile Include="NSpec\stack_specs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -0,0 +1,48 @@
using System.Linq;
using System.Reflection;
using NSpec;
using NSpec.Domain;
using NSpec.Domain.Formatters;

/*
* Howdy,
*
* This is NSpec's DebuggerShim. It will allow you to use TestDriven.Net or Resharper's test runner to run
* NSpec tests that are in the same Assembly as this class.
*
* It's DEFINITELY worth trying specwatchr (http://nspec.org/continuoustesting). Specwatchr automatically
* runs tests for you.
*
* If you ever want to debug a test when using Specwatchr, simply put the following line in your test:
*
* System.Diagnostics.Debugger.Launch()
*
* Visual Studio will detect this and will give you a window which you can use to attach a debugger.
*/

//[TestFixture]
public class DebuggerShim
{
//[Test]
public void debug()
{
var tagOrClassName = "class_or_tag_you_want_to_debug";

var types = GetType().Assembly.GetTypes();
// OR
// var types = new Type[]{typeof(Some_Type_Containg_some_Specs)};

var finder = new SpecFinder(types, "");

var tagsFilter = new Tags().Parse(tagOrClassName);

var builder = new ContextBuilder(finder, tagsFilter, new DefaultConventions());

var runner = new ContextRunner(tagsFilter, new ConsoleFormatter(), false);

var results = runner.Run(builder.Contexts().Build());

//assert that there aren't any failures
results.Failures().Count().should_be(0);
}
}
@@ -0,0 +1,5 @@
# NSpec

* Dependencies: -
* NuGet: https://www.nuget.org/packages/nspec/
* Source: https://github.com/mattflo/nspec
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using NSpec;

namespace ConductOfCode.NSpec
{
class stack_specs : nspec
{
void empty_()
{
before = () => stack = new Stack<int>();

it["has no elements"] = () => stack.Count.should_be(0);
it["throws an exception when calling pop"] = () => expect<InvalidOperationException>(() => stack.Pop());
it["throws an exception when calling peek"] = () => expect<InvalidOperationException>(() => stack.Peek());
}

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

it["returns the top element when calling peek"] = () => stack.Peek().should_be(3);
it["does not remove the top element when calling peek"] = () =>
{
stack.Peek();
stack.should_contain(3);
};
it["returns the top element when calling pop"] = () => stack.Pop().should_be(3);
it["removes the top element when calling pop"] = () =>
{
stack.Pop();
stack.should_not_contain(3);
};
}

Stack<int> stack;
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.13283" newVersion="2.6.3.13283" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -5,5 +5,6 @@
<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="nspec" version="1.0.7" targetFramework="net46" />
<package id="NUnit" version="2.6.3" targetFramework="net46" />
</packages>

0 comments on commit dc8a8b5

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