示例#1
0
 public async Task ListRoles_NoRoles_Ok()
 {
     var target = new RolesController();
     var actual = (ViewResult)(await target.Index());
     var roles = actual.Model as IEnumerable<RoleViewModel>;
     roles.ShouldNotBeNull().ShouldBeEmpty();
 }
示例#2
0
 public async Task EditMembers_NoMembers_Ok()
 {
     var role = await CreateRole("testing");
     
     var target = new RolesController();
     var actual = await target.EditMembers(role.Name) as ViewResult;
     actual.ShouldNotBeNull();
     var model = actual.Model as EditRoleMembersViewModel;
     model.ShouldNotBeNull();
     model.AvailableUsers.ShouldNotBeNull().ShouldBeEmpty();
     model.CurrentMembers.ShouldNotBeNull().ShouldBeEmpty();
 }
示例#3
0
        public async Task ListRoles_1Role_Ok()
        {
            var targetRole = await CreateRole("testing");
            
            var target = new RolesController();
            var actual = (ViewResult)(await target.Index());
            var roles = actual.Model as IEnumerable<RoleViewModel>;
            roles.ShouldNotBeNull();
            roles.Count().ShouldEqual(1);

            var firstRole = roles.First();
            firstRole.Name.ShouldEqual(targetRole.Name);
            firstRole.Id.ShouldEqual(targetRole.Id);
        }
示例#4
0
        public async Task EditMembers_1Member_Ok()
        {
            var role = await CreateRole("testing");
            var user = await CreateUser("tester");

            var identityResult = await _userManager.AddToRoleAsync(user.Id, role.Name);
            identityResult.Succeeded.ShouldBeTrue();

            var target = new RolesController();
            var actual = await target.EditMembers(role.Name) as ViewResult;
            actual.ShouldNotBeNull();
            var model = actual.Model as EditRoleMembersViewModel;
            model.ShouldNotBeNull();
            model.AvailableUsers.ShouldNotBeNull().ShouldBeEmpty();
            model.CurrentMembers.Count().ShouldEqual(1);
        }
示例#5
0
        public async Task AddUserToRoleTest()
        {
            var role = await CreateRole("testing");
            var user = await CreateUser("tester");

            var target = new RolesController();
            var request = new AddUserToRoleViewModel() { RoleName = role.Name, UserId = user.Id };
            var actual = await target.AddUserToRole(request) as ViewResult;

            using (var ctx = new ApplicationDbContext())
            {
                var dbUser = ctx.Users.Find(user.Id);
                dbUser.Roles.Count.ShouldEqual(1);
            }
        }