Created
April 17, 2012 06:55
-
-
Save agileguy/2404061 to your computer and use it in GitHub Desktop.
MVC Integration Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web; | |
using System.Web.Mvc; | |
using MvcIntegrationTestFramework.Hosting; | |
using NUnit.Framework; | |
using website.Properties; | |
namespace website.tests | |
{ | |
[TestFixture] | |
public class HomeControllerIndexTests | |
{ | |
[TestFixtureSetUp] | |
public void Setup() | |
{ | |
appHost = AppHost.Simulate("Website"); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsTheIndexView() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.AreEqual("Index", ((ViewResult)result.ActionExecutedContext.Result).ViewName); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsCorrectRouteData() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.AreEqual("Home", result.ActionExecutedContext.RouteData.Values["controller"]); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsViewResult() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.IsInstanceOf(typeof(ViewResult), result.ActionExecutedContext.Result); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsNoError() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.IsNull(result.ResultExecutedContext.Exception); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsViewWithSiteCssFile() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.IsTrue(result.ResponseText.Contains("/Content/Site.css")); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsViewWithCorrectTitle() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
Assert.IsTrue(result.ResponseText.ToLowerInvariant().Contains("<title>{ me: danielelliott.info(); }</title>")); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexReturnsViewContainingBanner() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
var expected = HttpUtility.HtmlEncode(Resources.SiteName); | |
Assert.IsTrue(result.ResponseText.Contains(expected)); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexViewIncludesBioParagraph() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
var expected = HttpUtility.HtmlEncode(Resources.Bio.ToLowerInvariant()); | |
Assert.IsTrue(result.ResponseText.ToLowerInvariant().Contains(expected)); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexViewIncludesServicesParagraph() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
var expected = HttpUtility.HtmlEncode(Resources.Services.ToLowerInvariant()); | |
Assert.IsTrue(result.ResponseText.ToLowerInvariant().Contains(expected)); | |
}); | |
} | |
[Test] | |
public void HomeControllerIndexViewIncludesHistoryParagraph() | |
{ | |
appHost.Start(session => | |
{ | |
var result = session.Get("/Home/Index"); | |
var expected = HttpUtility.HtmlEncode(Resources.History.ToLowerInvariant()); | |
Assert.IsTrue(result.ResponseText.ToLowerInvariant().Contains(expected)); | |
}); | |
} | |
private AppHost appHost; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment