public void Index_AsksForIndexView() { Mock <RoleStore <AppRole> > roleStore = new Mock <RoleStore <AppRole> >(); AppRoleManager roleManager = new AppRoleManager(roleStore.Object); RoleAdminController controller = GetNewRoleAdminController(null, roleManager); ViewResult result = controller.Index() as ViewResult; Assert.AreEqual("Index", result.ViewName); }
public void Index_RetrievesNamePropertyFromModel() { Mock <RoleStore <AppRole> > roleStore = new Mock <RoleStore <AppRole> >(); Mock <AppRoleManager> roleManager = new Mock <AppRoleManager>(roleStore.Object); roleManager.Setup(m => m.Roles).Returns(new AppRole[] { new AppRole { Name = "Users" } }.AsQueryable()); RoleAdminController controller = GetNewRoleAdminController(null, roleManager.Object); ViewResult result = controller.Index() as ViewResult; IQueryable <AppRole> model = result.ViewData.Model as IQueryable <AppRole>; Assert.AreEqual(1, model.Count()); Assert.AreEqual("Users", model.ToArray()[0].Name); }