public void GivenAnInvalidExpirationDate_WhenCreatingACreditCard_ThenAnExceptionIsThrown() { var builder = new CreditCard.Builder() .Numbered(VALID_CREDIT_CARD_NUMBER) .OwnedBy(VALID_CREDIT_CARD_OWNER) .ExpiresOn(-1, -1); var exception = Assert.Throws <ArgumentException>(() => builder.Build()); Assert.Equal(YearMonth.DATE_IS_INVALID_ERROR, exception.Message); }
public void GivenACurrentDateTimeHigherThanExpirationDate_WhenCreatingACreditCard_ThenAnExceptionIsThrown(int expirationYear, int expirationMonth) { var builder = new CreditCard.Builder() .Numbered(VALID_CREDIT_CARD_NUMBER) .OwnedBy(VALID_CREDIT_CARD_OWNER) .ExpiresOn(expirationYear, expirationMonth) .CheckingOn(new DateTime(VALID_YEAR, VALID_MONTH, 1)); var exception = Assert.Throws <ArgumentException>(() => builder.Build()); Assert.Equal(CreditCard.CARD_HAS_EXPIRED_ERROR, exception.Message); }
public void GivenAnInvalidOwner_WhenCreatingACreditCard_ThenAnExceptionIsThrown(string invalidName) { var builder = new CreditCard.Builder() .Numbered(VALID_CREDIT_CARD_NUMBER) .OwnedBy(invalidName) .ExpiresOn(2020, 12) .CheckingOn(2020, 4); var exception = Assert.Throws <ArgumentException>(() => builder.Build()); Assert.Equal(CreditCard.OWNER_IS_INVALID_ERROR, exception.Message); }