public async void SignIn_CorrectInput_ReturnSucceeded() { // arrang Models.SignInInfo info = new Models.SignInInfo { Account = FakeUser.Email, Password = FakeUser.PasswordHash }; IAccountManager <UserManager> accountManager = new UserManager(_db, redisConn); // act var user = await accountManager.SignInAsync(info); // assert Assert.NotNull(user); }
public async void SignIn_WrongPassword_ReturnSucceeded() { // arrang const string WRONG_PASSWORD = "******"; Models.SignInInfo info = new Models.SignInInfo { Account = FakeUser.Email, Password = WRONG_PASSWORD }; IAccountManager <UserManager> accountManager = new UserManager(_db, redisConn); // act var user = await accountManager.SignInAsync(info); // assert Assert.Null(user); }
public async void GenerateToken_CorrectInput_ReturnToken() { // arrang Models.SignInInfo info = new Models.SignInInfo { Account = FakeUser.Email, Password = FakeUser.PasswordHash }; IAccountManager <UserManager> accountManager = new UserManager(_db, redisConn); ScreamBackend.DB.Tables.User userModel; // act var user = await accountManager.SignInAsync(info); await user.GenerateClaimsAsync(); userModel = await _db.Users.AsNoTracking().SingleOrDefaultAsync(u => u.NormalizedEmail == FakeUser.NormalizedEmail); // assert Assert.NotNull(user); Assert.False(string.IsNullOrWhiteSpace(userModel.Token)); }
public async void SignOut_SignInInput_ReturnEmptyToken() { // arrange const string EXPECT_TOKEN = ""; Models.SignInInfo info = new Models.SignInInfo { Account = FakeAdmin.Email, Password = FakeAdmin.PasswordHash }; IAccountManager <UserManager> accountManager = new UserManager(_db, redisConn); string actualToken; // act var user = await accountManager.SignInAsync(info); await user.SignOutAsync(); actualToken = (await _db.Users.AsNoTracking().SingleAsync(u => u.NormalizedEmail == FakeUser.NormalizedEmail)).Token; // assert Assert.Equal(EXPECT_TOKEN, actualToken); }