예제 #1
0
        public async Task PutVerbIsNotAccepted()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            var response = await TestFixture.Client.PutAsync("/payment", ContentHelpers.JsonString(payment));

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.MethodNotAllowed));
        }
예제 #2
0
        public async Task PaymentDataWithInvalidCreditCardNumberIsNotAccepted()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            payment.CardNumber = "nosuch";

            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            await HttpAssert.IsBadRequestWithJsonContent(response);
        }
예제 #3
0
        public async Task PaymentDataWithoutNameIsNotAccepted()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            payment.NameOnCard = string.Empty;

            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            await HttpAssert.IsBadRequestWithJsonContent(response);
        }
예제 #4
0
        public async Task BankRejectionHasCorrectStatus()
        {
            var payment = PaymentRequestBuilder.RequestToBeRejected();

            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            var paymentResponse = await ReadAsPaymentData(response);

            Assert.That(paymentResponse.Status, Is.EqualTo(PaymentStatus.Rejected));
        }
예제 #5
0
        public async Task ValidPaymentDataIsAccepted()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            var paymentResponse = await ReadAsPaymentData(response);

            Assert.That(paymentResponse.Status, Is.EqualTo(PaymentStatus.Accepted));
        }
예제 #6
0
        private static async Task <Guid> SubmitPayment(PaymentRequest payment)
        {
            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));

            var responseContent = await response.Content.ReadAsStringAsync();

            var paymentResponse = JsonConvert.DeserializeObject <PaymentData>(responseContent);

            Assert.That(paymentResponse, Is.Not.Null);
            return(paymentResponse.Id);
        }
예제 #7
0
        public async Task AmexCardNumberIsAccepted()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            payment.CardNumber = "378282246310005";
            payment.CardCvv    = "1234";

            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString(payment));

            var paymentResponse = await ReadAsPaymentData(response);

            Assert.That(paymentResponse.Status, Is.EqualTo(PaymentStatus.Accepted));
        }
예제 #8
0
        public async Task NoPaymentDataIsBadRequest()
        {
            var response = await TestFixture.Client.PostAsync("/payment", ContentHelpers.JsonString("{}"));

            await HttpAssert.IsBadRequestWithJsonContent(response);
        }