public
Created

  • Download Gist
gistfile1.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
[TestFixture]
public class AdminControllerBehaviors
{
[Test]
public void When_requesting_the_admin_categories_page_result_is_correct()
{
const string expectedViewName = "Categories";
var repository = new Mock<IRpository<Category>>();
var controller = new AdminController(repository.Object);
var result = controller.Categories();
result.Should().BeAssignableTo<ActionResult>();
((ViewResult) result).ViewName.Should().Be(expectedViewName);
}
 
[Test]
public void When_requesting_the_admin_categories_add_page_result_is_correct()
{
const string expectedViewName = "Categories";
var repository = new Mock<IRpository<Category>>();
var controller = new AdminController(repository.Object);
var result = controller.CategoriesAdd();
result.Should().BeAssignableTo<ActionResult>();
((ViewResult)result).ViewName.Should().Be(expectedViewName);
}
 
[Test]
public void When_requesting_the_admin_categories__add_post_page_result_is_correct()
{
var repository = new Mock<IRpository<Category>>();
var controller = new AdminController(repository.Object);
var viewModel = new CategoriesAddViewModel();
var result = controller.CategoriesAdd(viewModel);
result.Should().BeAssignableTo<RedirectToRouteResult>();
((RedirectToRouteResult)result).RouteValues["Action"].Should().Be("Categories");
((RedirectToRouteResult)result).RouteValues["Controller"].Should().Be("Admin");
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.