public async void UnbanUserProfile_UserNotFound() { var store = new Mock <IUserRoleStore <UserProfile> >(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(() => null); store.Setup(s => s.UpdateAsync(null, It.IsAny <CancellationToken>())).ThrowsAsync(new NullReferenceException()); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await Assert.ThrowsAsync(new NullReferenceException().GetType(), () => administrationService.UnbanUserProfile("")); }
public async void UnbanUserProfile_UserFound() { var testUser = new UserProfile { IsBanned = true }; var store = new Mock <IUserRoleStore <UserProfile> >(); store.Setup(s => s.FindByIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(testUser); store.Setup(s => s.UpdateAsync(It.IsAny <UserProfile>(), It.IsAny <CancellationToken>())).ReturnsAsync(IdentityResult.Success).Callback(() => testUser.IsBanned = false); var userManager = new UserManager <UserProfile>(store.Object, null, null, null, null, null, null, null, null); var administrationService = new AdministrationService(null, userManager); await administrationService.UnbanUserProfile(""); Assert.False(testUser.IsBanned); }