Exemplo n.º 1
0
        public void CardExpiryDate_GivenSameValue_ShouldBeEqual()
        {
            var expiryYearMonthString = "01/20";
            var sut1 = CardExpiryDate.For(expiryYearMonthString);
            var sut2 = CardExpiryDate.For(expiryYearMonthString);

            sut1.ShouldBe(sut2);
        }
Exemplo n.º 2
0
        public void CardExpiryDate_GivenDifferentValue_ShouldNotEqualOnOperator()
        {
            var sut1 = CardExpiryDate.For("01/20");
            var sut2 = CardExpiryDate.For("02/22");

            sut1.Should().NotBe(sut2);
            sut1.Equals(sut2).Should().BeFalse();
            (sut1 != sut2).Should().BeTrue();
        }
Exemplo n.º 3
0
 public Payment(int merchantId, string cardHolderName, string cardNumber, string cardExpiryDate, string cvv, decimal amount)
 {
     Id             = Guid.NewGuid();
     MerchantId     = merchantId;
     CardHolderName = cardHolderName;
     CardNumber     = new CardNumber(cardNumber);
     CardExpiryDate = CardExpiryDate.For(cardExpiryDate);
     Cvv            = cvv;
     Amount         = amount;
 }
Exemplo n.º 4
0
        public void CardExpiryDate_ShouldConvertToStringImplicitly()
        {
            var expiryYearMonthString = "01/20";
            var sut = CardExpiryDate.For(expiryYearMonthString);

            string converted = sut;

            sut.Value.ToString("dd/MM/yyyy").Should().Be("31/01/2020");
            converted.Should().Be(expiryYearMonthString);
        }
Exemplo n.º 5
0
        public void CardExpiryDate_GivenExpiryYearMonthString_ShouldCreateExpiryDate(string expiryYearMonthString, string expiryDate)
        {
            var sut = CardExpiryDate.For(expiryYearMonthString);

            // Date property should be the end of month
            sut.Value.ToString("dd/MM/yyyy").Should().Be(expiryDate);

            // ToString is overriden to return original input
            sut.ToString().Should().Be(expiryYearMonthString);
        }
Exemplo n.º 6
0
 public Payment(Guid id, int merchantId, string cardHolderName, string cardNumber, string expiryYearMonthString, string cvv, decimal amount, string currency)
 {
     Id             = id;
     MerchantId     = merchantId;
     CardHolderName = cardHolderName;
     CardNumber     = new MaskedString(cardNumber);
     CardExpiryDate = CardExpiryDate.For(expiryYearMonthString);
     Cvv            = cvv;
     Money          = new Money(amount, currency);
 }
Exemplo n.º 7
0
        public void CardExpiryDate_GivenWrongInput_ShouldRaiseCardExpiryDateInvalidException(string cardExpiryYearMonthString)
        {
            Action act = () => CardExpiryDate.For(cardExpiryYearMonthString);

            act.Should().Throw <CardExpiryDateInvalidException>();
        }
Exemplo n.º 8
0
 public void CardExpiryDate_GivenWrongInput_ShouldRaiseCardExpiryDateInvalidException(string cardExpiryYearMonthString)
 {
     Should.Throw <CardExpiryDateInvalidException>(() => CardExpiryDate.For(cardExpiryYearMonthString));
 }