Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created February 2, 2013 15:48
Show Gist options
  • Save jmarnold/4697920 to your computer and use it in GitHub Desktop.
Save jmarnold/4697920 to your computer and use it in GitHub Desktop.
Sample integration testing
[TestFixture]
public class IntegrationTestExample
{
// You'll want the FubuMVC.Katana package for this
private EmbeddedFubuMvcServer theServer;
[SetUp]
public void SetUp()
{
theServer = new MyApplication().RunEmbedded();
}
[TearDown]
public void Teardown()
{
theServer.Dispose();
}
[Test]
public void do_something()
{
var input = new SomeInputModel { value = "test" };
var response = theServer.Endpoints.PostJson(input);
response.ReadAsText().ShouldEqual("Hello");
}
}
// Using a separate class for bootstrapping makes it much easier to reuse your application
// in testing scenarios with either SelfHost or OWIN/Katana hosting
public class MyApplication : IApplicationSource
{
public FubuApplication BuildApplication()
{
return FubuApplication
.For<MyFubuMvcPolicies>()
.StructureMap(new Container());
}
}
public class MyFubuPolicies : FubuRegistry
{
public MyFubuPolicies()
{
// This is a DSL to change or add new conventions, policies, or application settings
}
}
@jvandertil
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment