Пример #1
0
        public void Should_not_be_equal_to_another_instance_if_they_dont_have_same_number()
        {
            var ccvA = Ccv.Create(123);
            var ccvB = Ccv.Create(321);

            ccvA.Should().NotBe(ccvB);
        }
Пример #2
0
        public static Payment Create(IProvideDateTime dateProvider)
        {
            var expiryDate = ExpiryDate.Create(08, 2020, dateProvider);
            var cardNumber = CardNumber.Create("4111 1111 1111 1111");
            var ccv        = Ccv.Create(123);

            var paymentId  = PaymentId.Create();
            var creditCard = CreditCard.Create(cardNumber, expiryDate, ccv);
            var amount     = Money.Create(12, Currency.EUR);

            return(new Payment(paymentId, creditCard, amount));
        }
        public async Task <PaymentId> CreatePayment(string cardNumber, int ccv, int expiryMonthDate, int expiryYearDate, double amount, Currency currency)
        {
            var card = CreditCard.Create(CardNumber.Create(cardNumber),
                                         ExpiryDate.Create(expiryMonthDate, expiryYearDate, _dateProvider),
                                         Ccv.Create(ccv));
            var money   = Money.Create(amount, currency);
            var payment = new Payment(PaymentId.Create(), card, money);

            await _paymentRepository.Save(payment);

            return(payment.Id);
        }
Пример #4
0
        public CreditCardTests()
        {
            // Substitutes
            var today = new DateTimeOffset(new DateTime(2019, 08, 19, 0, 0, 0, DateTimeKind.Utc));

            _dateProvider = Substitute.For <IProvideDateTime>();
            _dateProvider.UtcNow().Returns(today);

            // Shared objects
            _cardNumber = CardNumber.Create("4111 1111 1111 1111");
            _ccv        = Ccv.Create(123);
            _expiryDate = ExpiryDate.Create(09, 2019, _dateProvider);
        }
Пример #5
0
        public void Should_be_equal_to_another_instance_if_they_do_not_have_same_details()
        {
            var cardNumberA = CardNumber.Create("4111 1111 1111 1111");
            var ccvA        = Ccv.Create(123);
            var expiryDateA = ExpiryDate.Create(09, 2019, _dateProvider);
            var creditCardA = CreditCard.Create(cardNumberA, expiryDateA, ccvA);


            var cardNumberB = CardNumber.Create("4111 1111 1111 1111");
            var ccvB        = Ccv.Create(123);
            var expiryDateB = ExpiryDate.Create(09, 2020, _dateProvider); // Diff is here
            var creditCardB = CreditCard.Create(cardNumberB, expiryDateB, ccvB);

            creditCardA.Should().NotBe(creditCardB);
        }
Пример #6
0
        public void Should_create_an_instance_when_the_ccv_number_has_3_digits()
        {
            var instance = Ccv.Create(123);

            instance.Should().NotBeNull();
        }
Пример #7
0
        public void Should_raise_an_error_when_the_ccv_number_does_not_have_3_digits(int number)
        {
            Action action = () => Ccv.Create(number);

            action.Should().Throw <ValidationException>();
        }