public void CardExpiryDate_GivenSameValue_ShouldBeEqual() { var expiryYearMonthString = "01/20"; var sut1 = CardExpiryDate.For(expiryYearMonthString); var sut2 = CardExpiryDate.For(expiryYearMonthString); sut1.ShouldBe(sut2); }
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(); }
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; }
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); }
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); }
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); }
/// <summary> /// Returns true if PaymentResponse instances are equal /// </summary> /// <param name="other">Instance of PaymentResponse to be compared</param> /// <returns>Boolean</returns> public bool Equals(PaymentResponse other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( CurrencyCode == other.CurrencyCode || CurrencyCode != null && CurrencyCode.Equals(other.CurrencyCode) ) && ( Amount == other.Amount || Amount != null && Amount.Equals(other.Amount) ) && ( CVC == other.CVC || CVC != null && CVC.Equals(other.CVC) ) && ( CardNumber == other.CardNumber || CardNumber != null && CardNumber.Equals(other.CardNumber) ) && ( FullName == other.FullName || FullName != null && FullName.Equals(other.FullName) ) && ( CardExpiryDate == other.CardExpiryDate || CardExpiryDate != null && CardExpiryDate.Equals(other.CardExpiryDate) ) && ( RequestDate == other.RequestDate || RequestDate != null && RequestDate.Equals(other.RequestDate) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (CurrencyCode != null) { hashCode = hashCode * 59 + CurrencyCode.GetHashCode(); } if (Amount != null) { hashCode = hashCode * 59 + Amount.GetHashCode(); } if (CVC != null) { hashCode = hashCode * 59 + CVC.GetHashCode(); } if (CardNumber != null) { hashCode = hashCode * 59 + CardNumber.GetHashCode(); } if (FullName != null) { hashCode = hashCode * 59 + FullName.GetHashCode(); } if (CardExpiryDate != null) { hashCode = hashCode * 59 + CardExpiryDate.GetHashCode(); } if (RequestDate != null) { hashCode = hashCode * 59 + RequestDate.GetHashCode(); } if (SendingBankName != null) { hashCode = hashCode * 59 + SendingBankName.GetHashCode(); } if (RecievingBankName != null) { hashCode = hashCode * 59 + RecievingBankName.GetHashCode(); } return(hashCode); } }
public void CardExpiryDate_GivenWrongInput_ShouldRaiseCardExpiryDateInvalidException(string cardExpiryYearMonthString) { Action act = () => CardExpiryDate.For(cardExpiryYearMonthString); act.Should().Throw <CardExpiryDateInvalidException>(); }
public void CardExpiryDate_GivenWrongInput_ShouldRaiseCardExpiryDateInvalidException(string cardExpiryYearMonthString) { Should.Throw <CardExpiryDateInvalidException>(() => CardExpiryDate.For(cardExpiryYearMonthString)); }
public void SetUp() { _target = new CardExpiryDate(); }