コード例 #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
        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));
        }
コード例 #7
0
        public async Task StoredDataIsCorrect()
        {
            var paymentRequest = PaymentRequestBuilder.ValidPaymentRequest();
            var paymentId      = await SubmitPayment(paymentRequest);

            var getResponse = await TestFixture.Client.GetAsync($"/payment/{paymentId}");

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

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


            Assert.That(bankResponse.Id, Is.EqualTo(paymentId));
            Assert.That(bankResponse.Amount, Is.EqualTo(paymentRequest.Amount));
            Assert.That(bankResponse.NameOnCard, Is.EqualTo(paymentRequest.NameOnCard));
            Assert.That(bankResponse.CardNumber, Is.EqualTo("4111"));
        }
コード例 #8
0
        private static async Task <Guid> GetValidPaymentId()
        {
            var payment = PaymentRequestBuilder.ValidPaymentRequest();

            return(await SubmitPayment(payment));
        }