public void BeAbleToReturnASinglePaymentInRepository() { IHttpActionResult actionResult = CONTROLLER.GetPayment(FIRST_PAYMENT.ID); OkNegotiatedContentResult <Payment> contentResult = (OkNegotiatedContentResult <Payment>)actionResult; Assert.AreEqual(contentResult.Content, FIRST_PAYMENT); }
public async Task Get_Payment_Returns_NotFound_When_Payment_Does_Not_Exist() { _mediator .Setup(_ => _.Send(It.IsAny <GetPaymentQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(Response.Failure <Payment>("nope")); var response = await _sut.GetPayment(Guid.Empty); Assert.IsAssignableFrom <NotFoundResult>(response.Result); }
public async Task GivenNotExistingPayment_WhenGetPaymentIsCalled_ThenNotFoundIsReturned() { var transactionId = Guid.NewGuid(); _mediator.Send(Arg.Is <GetPaymentByTransactionIdQuery>(r => r.TransactionId.Equals(transactionId) && r.ApiKey.Equals(_apiKey))) .Returns(new Result <GetPaymentByTransactionIdQueryResponse>()); var response = await _controller.GetPayment(transactionId); response.Should().BeOfType <NotFoundResult>(); }
public async Task TestGetPaymentNotCurrentMerchant() { var payment = GetPayment(UnknownMerchantId); PaymentDb.Payments.Add(payment); await PaymentDb.SaveChangesAsync(); var response = await Subject.GetPayment(payment.Id); Assert.IsInstanceOfType(response.Result, typeof(NotFoundResult)); Assert.IsNull(response.Value); }
public void GetPayment_ConstructsQuery_ReturnsResultOfDispatch() { var resultDto = new Dto.PaymentDto(); var query = new GetPayment(TestIds.A); _dispatcherMock.Setup(d => d.QueryAsync(query)).ReturnsAsync(resultDto).Verifiable(); var actionResult = _controller.GetPayment(query).GetAwaiter().GetResult(); Assert.AreEqual(resultDto, actionResult.Value); _dispatcherMock.Verify(); }
public async Task GetPayment_Returns400BadRequest_WhenIdIsNull() { // Arrange string id = null; // Act var action = await _sut.GetPayment(id); var actionResult = action.Result as BadRequestObjectResult; // Assert Assert.AreEqual(actionResult.StatusCode, 400); }
public void BeAbleToReturnASinglePaymentInRepository() { List <IField> emptyFields = new List <IField>(); NumberField field = new NumberField("Monto"); emptyFields.Add(field); IField filledField = field.FillAndClone("100"); List <IField> fullFields = new List <IField>(); fullFields.Add(filledField); Provider provider = new Provider("Antel", 3, emptyFields); Receipt receipt = new Receipt(provider, fullFields, 100); List <Receipt> list = new List <Receipt>(); list.Add(receipt); Payment payment = new Payment(new CashPayMethod(DateTime.Now), 100, list); var mockPaymentService = new Mock <IPaymentService>(); mockPaymentService.Setup(x => x.GetSinglePayment(payment.ID)).Returns(payment); PaymentsController controller = new PaymentsController(mockPaymentService.Object); IHttpActionResult actionResult = controller.GetPayment(payment.ID); OkNegotiatedContentResult <Payment> contentResult = (OkNegotiatedContentResult <Payment>)actionResult; Assert.AreSame(contentResult.Content, payment); }
public void FailIfSinglePaymentIdDoesntExistInRepository() { List <IField> emptyFields = new List <IField>(); NumberField field = new NumberField("Monto"); emptyFields.Add(field); IField filledField = field.FillAndClone("100"); List <IField> fullFields = new List <IField>(); fullFields.Add(filledField); Provider provider = new Provider("Antel", 3, emptyFields); Receipt receipt = new Receipt(provider, fullFields, 100); List <Receipt> list = new List <Receipt>(); list.Add(receipt); Payment payment = new Payment(new CashPayMethod(DateTime.Now), 100, list); var mockPaymentService = new Mock <IPaymentService>(); mockPaymentService.Setup(x => x.GetSinglePayment(payment.ID + 1)).Throws(new ArgumentOutOfRangeException()); PaymentsController controller = new PaymentsController(mockPaymentService.Object); IHttpActionResult actionResult = controller.GetPayment(payment.ID + 1); Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public async Task GetPayment_ReturnsOkObjectResultOfTypeResponseCardPaymentDto() { // arrange var identifier = "aa297f35-5158-40b0-8529-29755ec7f456"; _mockPaymentRepository.Setup(repo => repo.GetPaymentAsync(It.IsAny <string>())).Returns(Task.FromResult(TestData.GetPayment())); _mockMapper.Setup(m => m.Map <Payment, ResponseCardPaymentDto>(It.IsAny <Payment>())).Returns(TestData.GetResponseCardPaymentDto()); // act var result = await _paymentsController.GetPayment(identifier); // assert var objectResult = Assert.IsType <OkObjectResult>(result); Assert.IsType <ResponseCardPaymentDto>(objectResult.Value); }
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { payment = controller.GetPayment(Int32.Parse(comboBox.Text.Split('-')[0])); textBox_amount.Text = payment.Amount.ToString(); datetime_due_date.Text = DateTime.Parse(payment.DueDate.ToString()).ToString(); textBox_description.Text = payment.Description; comboBox_paid.Text = payment.IsPaid ? "Yes" : "No"; }
public void TestGetPayment() { Moip.Models.PaymentRequest paymentRequest = Helpers.RequestsCreator.CreatePaymentWithCCRequest(); string paymentId = controller.CreateCreditCard(GetClient().Orders.CreateOrder(Helpers.RequestsCreator.createOrderRequest()).Id, paymentRequest).Id; Moip.Models.PaymentResponse paymentResponse = controller.GetPayment(paymentId); Assert.NotNull(paymentResponse.Id, "Id should not be null"); Assert.AreEqual(1, paymentResponse.InstallmentCount, "Should match exactly (string literal match)"); Assert.AreEqual("MyStore", paymentResponse.StatementDescriptor, "Should match exactly (string literal match)"); Assert.AreEqual("CREDIT_CARD", paymentResponse.FundingInstrument.Method, "Should match exactly (string literal match)"); Assert.AreEqual("Jose Goku da Silva", paymentResponse.FundingInstrument.CreditCard.Holder.Fullname, "Should match exactly (string literal match)"); Assert.AreEqual("1988-12-30", paymentResponse.FundingInstrument.CreditCard.Holder.Birthdate, "Should match exactly (string literal match)"); Assert.AreEqual("CPF", paymentResponse.FundingInstrument.CreditCard.Holder.TaxDocument.Type, "Should match exactly (string literal match)"); Assert.AreEqual("33333333333", paymentResponse.FundingInstrument.CreditCard.Holder.TaxDocument.Number, "Should match exactly (string literal match)"); }