Exemple #1
0
        public async Task Given_InvalidPayment_When_PostIsInvoked_Then_BadRequestIsReturned()
        {
            // arrange
            var paymentDto = new PaymentDto(
                785D,
                "EUR",
                new CreditCardDto(
                    "785",
                    "John Doe",
                    "78548569852364521",
                    this.futureMonth,
                    this.futureYear));

            var paymentResponseFailed = new PaymentResponseFailedDto();

            this.paymentService
            .Setup(p => p.PayAsync(It.IsAny <PaymentDto>()))
            .ReturnsAsync(paymentResponseFailed);

            // act
            var actionResult = await paymentController.Post(paymentDto);

            // assert
            Assert.True(actionResult.Result is BadRequestObjectResult);
            Assert.Equal((actionResult.Result as BadRequestObjectResult).StatusCode, (int)HttpStatusCode.BadRequest);
        }
Exemple #2
0
        public async Task Given_InvalidId_When_GetIsInvoked_Then_NotFoundIsReturned()
        {
            // arrange
            var id = default(Guid);

            var paymentResponseFailed = new PaymentResponseFailedDto();

            this.paymentService
            .Setup(p => p.GetAsync(It.IsAny <Guid>()))
            .ReturnsAsync(paymentResponseFailed);

            // act
            var actionResult = await paymentController.Get(id);

            // assert
            Assert.True(actionResult.Result is NotFoundObjectResult);
            Assert.Equal((actionResult.Result as NotFoundObjectResult).StatusCode, (int)HttpStatusCode.NotFound);
        }