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
[Test]
public void When_requesting_the_admin_categories_page_result_is_correct()
{
const int expectedCategoryCount = 3;
const string expectedViewName = "Categories";
var repository = new Mock<IRepository<Category>>();
 
repository.Setup(x => x.GetAll()).Returns(new List<Category>
{
new Category(),
new Category(),
new Category()
});
 
var controller = new AdminController(repository.Object);
var result = controller.Categories();
result.Should().BeAssignableTo<ActionResult>();
result.AssertViewRendered().ForView(expectedViewName);
result.Model.Should().BeAssignableTo<CategoriesListViewModel>();
 
((CategoriesListViewModel) result.Model).Categories.Count.Should().Be(expectedCategoryCount);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.