public void ShouldSearchUserProvider() { var i = 999; var searchUser = $"unitTest{i}"; var user = CreateUser(i); AddUser(user); var sut = new ExtendedUserProvider(TestSetup.DbFactory); var emailSearch = sut.FindUsersByEmail($"nit{i}@", 1, 100, out var emailTotal); var userNameSearch = sut.FindUsersByName($"est{i}", 1, 100, out var userNameTotal); var usersearch = sut.GetUser($"unittest{i}"); Assert.IsTrue(emailTotal == 1); Assert.IsTrue(emailSearch.First().Email == $"unit{i}@test.com"); Assert.IsTrue(userNameTotal == 1); Assert.IsTrue(userNameSearch.First().Username == searchUser); Assert.IsTrue(usersearch?.Username == searchUser); }
public async Task ShouldUpdateUsingExtendedUserRepositoryAsync() { var user = CreateUser(300); AddUser(user); var userTools = new ExtendedUserTools(TestSetup.DbFactory, null); var userProvider = new ExtendedUserProvider(TestSetup.DbFactory); var claims = new Claim[] { new Claim(ClaimTypes.Name, user.UserName) }; await userTools.SetExtendedRolesAsync(new ClaimsIdentity(claims, "UnitTest", ClaimTypes.Name, ClaimTypes.Role), new DateTime(2020, 01, 01)); var testUser = userProvider.GetUser(user.UserName); Assert.IsFalse(testUser.CreationDate == DateTime.MinValue); Assert.IsTrue(testUser.CreationDate.Year == 2020); Assert.IsTrue(testUser.CreationDate == testUser.LastLoginDate); RemoveUser(user, ctx => { }); }