public async Task GetPaymentsByMerchantId_When_MerchantId_Is_Null_Then_Return_BadRequest() { var controller = new ReadController(_logger, _mockReadService.Object); var expected = new BadRequestResult(); var actual = await controller.GetPaymentsByMerchantId(null); actual.Should().BeEquivalentTo(expected); }
public async Task GetPaymentsByMerchantId_When_Exception_Is_Thrown_Then_Return_InternalServerError() { var merchantId = 123123; var controller = new ReadController(_logger, _mockReadService.Object); _mockReadService.Setup(x => x.GetByMerchantId(It.IsAny <int>())) .ThrowsAsync(new Exception()); var expected = new StatusCodeResult(500); var actual = await controller.GetPaymentsByMerchantId(merchantId); actual.Should().BeEquivalentTo(expected); _mockReadService.Verify(); }
public async Task GetPaymentsByMerchantId_When_MerchantId_Has_Zero_Then_Return_Ok_With_Empty_List() { var merchantId = 123; var payments = new List <Payment>(); _mockReadService .Setup(x => x.GetByMerchantId(merchantId)) .ReturnsAsync(payments); var controller = new ReadController(_logger, _mockReadService.Object); var expected = new OkObjectResult(payments); var actual = await controller.GetPaymentsByMerchantId(merchantId); actual.Should().BeEquivalentTo(expected); _mockReadService.Verify(); }
public async Task GetPaymentsByMerchantId_When_MerchantId_Has_Payments_Then_Return_Ok_With_Payment_List() { var merchantId = 123; var payments = new List <Payment> { new Payment() { PaymentId = 321, MerchantId = merchantId, Amount = 432.23m, Currency = "USD" } }; _mockReadService .Setup(x => x.GetByMerchantId(merchantId)) .ReturnsAsync(payments); var controller = new ReadController(_logger, _mockReadService.Object); var expected = new OkObjectResult(payments); var actual = await controller.GetPaymentsByMerchantId(merchantId); actual.Should().BeEquivalentTo(expected); _mockReadService.Verify(); }