public async void WithNotBannedUser_ShouldThrowException() { var dbContext = this.GetDbContext(); var mockedUserManager = CommonGetMockMethods.GetUserManager(); CommonSetupMockMethods.SetupMockedUserManagerIsInRoleAsync(mockedUserManager, true); var service = this.GetService(dbContext, mockedUserManager.Object); var dbUser = SeedUsersMethods.SeedUserWithRole(dbContext); var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.UnbanUserAsync(dbUser.Id)); Assert.Equal(ErrorConstants.IncorrectUser, exception.Message); }
public async void WithNotBanned_ShouldBanUser() { var dbContext = this.GetDbContext(); var mockedUserManager = CommonGetMockMethods.GetUserManager(); CommonSetupMockMethods.SetupMockedUserManagerIsInRoleAsync(mockedUserManager, true); var service = this.GetService(dbContext, mockedUserManager.Object); var dbUser = SeedUsersMethods.SeedUserWithRole(dbContext); await service.BanUserAsync(dbUser.Id); Assert.True(dbUser.LockoutEnd > DateTime.UtcNow); }
public async void WithBannedUser_ShouldUnbanUser() { var dbContext = this.GetDbContext(); var mockedUserManager = CommonGetMockMethods.GetUserManager(); CommonSetupMockMethods.SetupMockedUserManagerIsInRoleAsync(mockedUserManager, true); var service = this.GetService(dbContext, mockedUserManager.Object); var dbUser = SeedUsersMethods.SeedUserWithRole(dbContext); this.BanUser(dbContext, dbUser); await service.UnbanUserAsync(dbUser.Id); Assert.Null(dbUser.LockoutEnd); }