Skip to content

Instantly share code, notes, and snippets.

@marcusoftnet
Created September 12, 2011 18:35
Show Gist options
  • Save marcusoftnet/1212018 to your computer and use it in GitHub Desktop.
Save marcusoftnet/1212018 to your computer and use it in GitHub Desktop.
Testing Nancy modules
using System.Collections.Generic;
using Nancy;
using Nancy.Bootstrapper;
using NSubstitute;
using NUnit.Framework;
namespace UnitTests
{
[TestFixture]
public class AbbeQuotesModuleTests
{
public IQouteRepository fakeQouteRepository;
[SetUp]
public void Setup()
{
// Create a fake repository
var fakeQouteRepository = Substitute.For<IQouteRepository>();
// Configure a bootstrapper that only contains the module you have
// under test and any any fake objects you want.
// EEEH - Say what?
// I'm not sure what to do here
}
[Test]
public void should_return_top_3_qoutes_when_getting_index_page()
{
// In this test I simply want to request "/" on my QouteModule
// and then assert that a dynamic model with three Quotes has been returned
Assert.Inconclusive("Stupidity hinders this test from being written");
}
}
public interface IQouteRepository
{
IList<dynamic> GetTopThreeQoutes();
}
public class QouteModule : NancyModule
{
public QouteModule(IQouteRepository qouteRepository)
{
Get["/"] = _ =>
{
var topThreeQoutes = qouteRepository.GetTopThreeQoutes();
return View["Index", topThreeQoutes];
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment