Пример #1
0
        public void AddToRole()
        {
            MockRoleService service     = new MockRoleService();
            MockUserService userService = new MockUserService();
            RoleController  controller  = GetRoleController(service, userService);
            Role            role        = service.Roles[0];
            var             id          = role.RoleId;
            var             userId      = userService.Users[0].UserId;

            ActionResult result = controller.AddToRole(id, userId);

            Assert.AreEqual(1, role.Users.Count());

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;

            Assert.AreEqual("Details", redirectResult.RouteValues["action"]);
            Assert.AreEqual(id, redirectResult.RouteValues["id"]);
        }