public void WhenVerifyingAccountInCorrectlyAccountStatusRemainsPendingActivation() { var paymentAccountService = new DomainServices.PaymentAccountService(_ctx); var paymentAccountVerificationService = new DomainServices.PaymentAccountVerificationService(_ctx, _logger); var userId = Guid.NewGuid(); double depositAmount1 = 0.34; double depositAmount2 = 0.15; var paymentAccount = paymentAccountService.AddPaymentAccount(userId.ToString(), "James Rhodes", "053000219", "1234123412", "Savings"); paymentAccount.AccountStatus = Domain.AccountStatusType.PendingActivation; paymentAccountService.UpdatePaymentAccount(paymentAccount); _ctx.PaymentAccountVerifications.Add(new Domain.PaymentAccountVerification() { DepositAmount1 = depositAmount1, DepositAmount2 = depositAmount2, EstimatedSettlementDate = System.DateTime.Now, Id = Guid.NewGuid(), NumberOfFailures = 0, PaymentAccountId = paymentAccount.Id, Sent = System.DateTime.Now, Status = Domain.PaymentAccountVerificationStatus.Deliveried }); _ctx.SaveChanges(); var result = paymentAccountVerificationService.VerifyAccount(userId.ToString(), paymentAccount.Id.ToString(), 0.99, 0.01); Assert.AreEqual(paymentAccount.AccountStatus, Domain.AccountStatusType.PendingActivation); }
//POST /api/{userId}/paymentaccounts/{id}/verify_account public HttpResponseMessage VerifyAccount(string userId, string id, AccountVerificationRequest request) { DomainServices.PaymentAccountVerificationService verificationService = new DomainServices.PaymentAccountVerificationService(_ctx, _logger); double depositAmount1 = 0; double depositAmount2 = 0; Double.TryParse(request.depositAmount1.ToString(), out depositAmount1); Double.TryParse(request.depositAmount2.ToString(), out depositAmount2); if (depositAmount1 == 0 || depositAmount2 == 0) { var responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest); responseMessage.ReasonPhrase = "Invalid deposit amount specified"; return(responseMessage); } var result = verificationService.VerifyAccount(userId, id, depositAmount1, depositAmount2); if (!result) { var responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest); responseMessage.ReasonPhrase = "Not verified"; return(responseMessage); } return(new HttpResponseMessage(HttpStatusCode.OK)); }
//POST /api/{userId}/paymentaccounts/{id}/verify_account public HttpResponseMessage VerifyAccount(string userId, string id, AccountVerificationRequest request) { DomainServices.PaymentAccountVerificationService verificationService = new DomainServices.PaymentAccountVerificationService(_ctx, _logger); double depositAmount1 = 0; double depositAmount2 = 0; Double.TryParse(request.depositAmount1.ToString(), out depositAmount1); Double.TryParse(request.depositAmount2.ToString(), out depositAmount2); if (depositAmount1 == 0 || depositAmount2 == 0) { var responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest); responseMessage.ReasonPhrase = "Invalid deposit amount specified"; return responseMessage; } var result = verificationService.VerifyAccount(userId, id, depositAmount1, depositAmount2); if (!result) { var responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest); responseMessage.ReasonPhrase = "Not verified"; return responseMessage; } return new HttpResponseMessage(HttpStatusCode.OK); }
public void WhenVerifyingAccountInCorrectlyVerificationServiceReturnsFalse() { var paymentAccountService = new DomainServices.PaymentAccountService(_ctx); var paymentAccountVerificationService = new DomainServices.PaymentAccountVerificationService(_ctx, _logger); var userId = Guid.NewGuid(); double depositAmount1 = 0.34; double depositAmount2 = 0.15; var paymentAccount = paymentAccountService.AddPaymentAccount(userId.ToString(), "James Rhodes", "053000219", "1234123412", "Savings"); paymentAccount.AccountStatus = Domain.AccountStatusType.PendingActivation; paymentAccountService.UpdatePaymentAccount(paymentAccount); _ctx.PaymentAccountVerifications.Add(new Domain.PaymentAccountVerification() { DepositAmount1 = depositAmount1, DepositAmount2 = depositAmount2, EstimatedSettlementDate = System.DateTime.Now, Id = Guid.NewGuid(), NumberOfFailures = 0, PaymentAccountId = paymentAccount.Id, Sent = System.DateTime.Now, Status = Domain.PaymentAccountVerificationStatus.Deliveried }); _ctx.SaveChanges(); var result = paymentAccountVerificationService.VerifyAccount(userId.ToString(), paymentAccount.Id.ToString(), 0.99, 0.01); Assert.AreEqual(false, result); }