public void TestImmutabilityWhenChangingExpirationDate()
 {
     DiscountByDate original = new DiscountByDate(.1m, DateTime.Now);
     DiscountByDate verifier = new DiscountByDate(original);
     DiscountByDate extended = original.ExtendByDays(7);
     Assert.IsFalse(original.Equals(extended));
     Assert.IsTrue(original.Equals(verifier));
 }
Exemplo n.º 2
0
 public void TestProductDiscountWithValidDiscountByDate()
 {
     ProductId prodOneId = new ProductId("1");
     Product prodOne = new Product(prodOneId, 10m);
     DiscountByDate discount = new DiscountByDate(.1m, DateTime.Now.AddDays(1));
     decimal discountedPrice = prodOne.DiscountPrice(discount);
     Assert.IsTrue(discountedPrice == 9m);
 }
Exemplo n.º 3
0
 public DiscountByDate(DiscountByDate discount)
 {
     DiscountAmount = discount.DiscountAmount;
     ExpirationDate = discount.ExpirationDate;
 }
Exemplo n.º 4
0
 public decimal DiscountPrice(DiscountByDate discount)
 {
     return(discount != null && discount.ExpirationDate > DateTime.Now
         ? Price - (Price * discount.DiscountAmount)
         : Price);
 }
Exemplo n.º 5
0
 public DiscountByDate(DiscountByDate discount)
 {
     DiscountAmount = discount.DiscountAmount;
     ExpirationDate = discount.ExpirationDate;
 }
 public void VerifyExtendedDate()
 {
     DiscountByDate original = new DiscountByDate(.1m, DateTime.Now);
     DiscountByDate extended = original.ExtendByDays(7);
     Assert.IsTrue(extended.ExpirationDate == original.ExpirationDate.AddDays(7));
 }
 public void TestMatchSameValues()
 {
     DiscountByDate discount = new DiscountByDate(.1m, DateTime.Now);
     DiscountByDate identicalDiscount = new DiscountByDate(discount);
     Assert.IsTrue(discount.Equals(identicalDiscount));
 }
 public void TestMatchSameDateObject()
 {
     DiscountByDate discount = new DiscountByDate(.1m, DateTime.Now);
     Assert.IsTrue(discount.Equals(discount));
 }
 public void TestMatchDifferentValues()
 {
     DiscountByDate discount = new DiscountByDate(.1m, DateTime.Now);
     DiscountByDate differentDiscount = new DiscountByDate(.1m, DateTime.Today);
     Assert.IsFalse(discount.Equals(differentDiscount));
 }