public async Task DeleteAccountByUserIDAsync_UserAccountIsDelted_UserAccountSuccessfulyDeletes(int userId, string password) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserAccountSettingsRepository userAccountSettingsRepository = new UserAccountSettingRepository(dataGateway, connectionString); ICryptographyService cryptographyService = new CryptographyService(userAccountRepository); IAuthenticationService authenticationService = new AuthenticationService(userAccountRepository); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(userAccountRepository, userAccountSettingsRepository, cryptographyService, authenticationService); bool result = await userAccountSettingsManager.DeleteAccountByUserIDAsync(userId, password); if (!result) { Assert.IsTrue(false); } UserAccountModel model = await userAccountRepository.GetAccountById(userId); if (model.AccountStatus == "Deleted") { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task DeleteAccountByUserIDAsync_UserAccountIsDelted_UserAccountSuccessfulyDeletes(int userId, string password) { Mock <IUserAccountRepository> mockUserAccountRepository = new Mock <IUserAccountRepository>(); Mock <IUserAccountSettingsRepository> mockUserAccountSettingsRepository = new Mock <IUserAccountSettingsRepository>(); Mock <IAuthenticationService> mockAuthenticationService = new Mock <IAuthenticationService>(); Mock <ICryptographyService> mockCryptographyService = new Mock <ICryptographyService>(); mockAuthenticationService.Setup(x => x.AuthenticatePasswordWithUserId(password, userId)).Returns(Task.FromResult(true)); IAccountSettingsService userAccountSettingsManager = new AccountSettingsService(mockUserAccountRepository.Object, mockUserAccountSettingsRepository.Object, mockCryptographyService.Object, mockAuthenticationService.Object); bool result = await userAccountSettingsManager.DeleteAccountByUserIDAsync(userId, password); if (result == true) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }