Exemplo n.º 1
0
        public async Task When__UserStore_Add_To_Role__Expect__User_Added_To_Role()
        {
            string          roleName = "Report User";
            int             userId   = 1;
            ApplicationUser user     = await _userStore.FindByIdAsync(userId).ConfigureAwait(false);

            Assert.That(user, Is.Not.Null, "User not found");

            await _userStore.AddToRoleAsync(user, roleName).ConfigureAwait(false);

            _context.SaveChanges();

            IList <string> roles = await _userStore.GetRolesAsync(user).ConfigureAwait(false);

            string savedRole = roles.Where(p => p == roleName).FirstOrDefault();

            Assert.That(savedRole, Is.Not.Null, "User not added to role");
        }