public void Invalid_user_cannot_approve_invoicing_payment_method() { // set mock behaviour _accountRepository .Expect(p => p.GetAccount(3)) .Returns(new Account(3) { HasRequestedInvoicing = true, BillingMethod = BillingMethod.CreditCard }); _accountRepository .Expect(p => p.UpdateAccount(It.Is<Account>(a => (a.BillingMethod == BillingMethod.Invoice && a.HasRequestedInvoicing == false)))) .Returns(true); ApproveInvoicingRequest request = new ApproveInvoicingRequest() { AccountId = 3, IsApprovalGranted = true, User = CreateAgentUser() }; ApproveInvoicingResponse response =_service.ApproveInvoicing(request); Assert.IsFalse(response.IsSuccessful, response.Message); Assert.AreEqual(Constants.Messages.NO_PERMISSIONS, response.Message, "Message"); }
public void Deny_invoicing_payment_leaves_payment_method_as_creditcard() { // set mock behaviour _accountRepository .Expect(p => p.GetAccount(3)) .Returns(new Account(3) { HasRequestedInvoicing = true, BillingMethod = BillingMethod.CreditCard }); _accountRepository .Expect(p => p.UpdateAccount(It.Is<Account>(a => (a.BillingMethod == BillingMethod.CreditCard && a.HasRequestedInvoicing == false)))) .Returns(true); ApproveInvoicingRequest request = new ApproveInvoicingRequest() { AccountId = 3, IsApprovalGranted = false, User = CreateIUser() }; ApproveInvoicingResponse response =_service.ApproveInvoicing(request); Assert.IsTrue(response.IsSuccessful, response.Message); }
public void ApproveInvoicing_AccountAlreadySetToInvoicing() { _accountRepository .Expect(p => p.GetAccount(3)) .Returns(new Account(3) { BillingMethod = BillingMethod.Invoice }); ApproveInvoicingRequest request = new ApproveInvoicingRequest() { AccountId = 3, IsApprovalGranted = true, User = CreateIUser() }; ApproveInvoicingResponse response =_service.ApproveInvoicing(request); Assert.IsFalse(response.IsSuccessful); Assert.AreEqual("Account is already billing by Invoice", response.Message); }
public void ApproveInvoicing_AccountNotFound() { // set mock behaviour _accountRepository .Expect(p => p.GetAccount(4)) .Returns<Account>(null); ApproveInvoicingRequest request = new ApproveInvoicingRequest() { AccountId = 4, IsApprovalGranted = true, User = new User() { Username = "******" } }; ApproveInvoicingResponse response = _service.ApproveInvoicing(request); Assert.IsFalse(response.IsSuccessful); Assert.AreEqual("Account Id does not exist", response.Message); }
protected void ApproveInvoicing(object sender, EventArgs e) { if (Account.AccountId != null) { bool approval = ((Control)sender).ID == "ApproveInvoicingButton" ? true : false; var service = ServiceFactory.GetService<IContractService>(); var user = new User { Username = User.Identity.Name, IsAuthenticated = User.Identity.IsAuthenticated }; var request = new ApproveInvoicingRequest { AccountId = Account.AccountId.Value, IsApprovalGranted = approval, User = user }; var response = service.ApproveInvoicing(request); if (response.IsSuccessful) { pnlInvoicingApproval.Visible = false; Account.BillingMethod = BillingMethod.Invoice; // Enable controls. SetControlReadOnly(false); } else { UserMessage.SetFailure(response.Message); } } else { UserMessage.SetFailure("No account associated with this contact. Cannot approve"); } }