public async Task Returns_null_if_no_payment_with_that_id_exists()
        {
            var sut = new InMemoryPaymentRepository(NullLogger <InMemoryPaymentRepository> .Instance);

            var retrievedPayment = await sut.Get(Guid.NewGuid(), Guid.NewGuid());

            Assert.Null(retrievedPayment);
        }
        public async Task Returns_null_if_no_payment_with_that_id_exists_for_the_provided_merchant_id()
        {
            var sut = new InMemoryPaymentRepository(NullLogger <InMemoryPaymentRepository> .Instance);

            var(payment, merchantId) = (GeneratePayment(), Guid.NewGuid());
            await sut.Create(payment : payment, merchantId : merchantId);

            var retrievedPayment = await sut.Get(payment.Id, Guid.NewGuid());

            Assert.Null(retrievedPayment);
        }
Example #3
0
        public async Task When_authorise_payment_called_with_valid_request_then_payment_is_stored_with_creation_time()
        {
            var paymentsRepo          = new InMemoryPaymentRepository(NullLogger <InMemoryPaymentRepository> .Instance);
            var expectedCreatedAtTime = SystemClock.Instance.GetCurrentInstant().Minus(Duration.FromDays(5));
            var clockStub             = new ConstantTimeClockStub(expectedCreatedAtTime);
            var sut            = new PaymentController(paymentsRepo, new AlwaysApprovesPaymentAuthoriser(), clockStub, NullLogger <PaymentController> .Instance);
            var paymentRequest = _generatePaymentRequest();

            var result = await sut.Authorise(paymentRequest);

            var createdPayment = ExpectSuccessResponseWithCreatedPayment(result);
            var storedPayment  = await paymentsRepo.Get(createdPayment.Id, PaymentController.DefaultMerchant.Id);

            Assert.Equal(expectedCreatedAtTime, storedPayment.CreatedAt);
        }
        public async Task Can_retrieve_a_stored_payment_for_a_merchant_id()
        {
            var sut = new InMemoryPaymentRepository(NullLogger <InMemoryPaymentRepository> .Instance);

            var(payment, merchantId) = (GeneratePayment(), Guid.NewGuid());
            await sut.Create(payment : payment, merchantId : merchantId);

            var retrievedPayment = await sut.Get(payment.Id, merchantId);

            Assert.Equal(payment.Amount, retrievedPayment.Amount);
            Assert.Equal(payment.Card, retrievedPayment.Card);
            Assert.Equal(payment.Id, retrievedPayment.Id);
            Assert.Equal(payment.Description, retrievedPayment.Description);
            Assert.Equal(payment.Result, retrievedPayment.Result);
            Assert.Equal(payment.Timestamp, retrievedPayment.Timestamp);
        }