public async Task RestoreUserAccountAsyncShouldCallUserManager() { var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var testAccountRepository = new EfDeletableEntityRepository <Account>(context); var testAccounts = TestDataHelpers.GetTestData(); foreach (var testAccount in testAccounts) { if (testAccount.Id == 1) { testAccount.IsDeleted = true; } await testAccountRepository.AddAsync(testAccount); await testAccountRepository.SaveChangesAsync(); } var testAccountManagementService = new AccountManagementService(this.userManager.Object, this.userRepository.Object, testAccountRepository, this.positionService.Object, this.feePaymentsRepository.Object); await testAccountManagementService.RestoreUserAccountAsync("1", 1); this.userManager.Verify(u => u.RemoveFromRoleAsync(It.IsAny <ApplicationUser>(), It.IsAny <string>()), Times.Once); this.userManager.Verify(u => u.AddToRoleAsync(It.IsAny <ApplicationUser>(), It.IsAny <string>()), Times.Once); }
public async Task RestoreUserAccountAsyncShouldWorkCorrectly() { var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var testAccountRepository = new EfDeletableEntityRepository <Account>(context); var testAccounts = TestDataHelpers.GetTestData(); foreach (var testAccount in testAccounts) { if (testAccount.Id == 1) { testAccount.IsDeleted = true; } await testAccountRepository.AddAsync(testAccount); await testAccountRepository.SaveChangesAsync(); } var testAccountManagementService = new AccountManagementService(this.userManager.Object, this.userRepository.Object, testAccountRepository, this.positionService.Object, this.feePaymentsRepository.Object); await testAccountManagementService.RestoreUserAccountAsync("1", 1); var account = testAccountRepository .AllWithDeleted() .FirstOrDefault(a => a.Id == 1); Assert.IsFalse(account.IsDeleted); }