public void TestInitialize() { GetDiscountValueRepo = MockRepository.GenerateStub<IGetDiscountValue>(); GetDiscountValueRepo.Stub(r => r.GetItemFee(ItemTypes.Auction)).Return(25); GetDiscountValueRepo.Stub(r => r.GetItemFee(ItemTypes.BuyItNow)).Return(35); GetDiscountValueRepo.Stub(r => r.GetUsertypeDiscount(UserTypes.Company)).Return(15); GetDiscountValueRepo.Stub(r => r.GetUsertypeDiscount(UserTypes.Normal)).Return(10); GetDiscountValueRepo.Stub(r => r.GetEndDateDiscount(ItemTypes.Auction,DateTime.Today)).Return(10); FeeCalculationRepo = MockRepository.GenerateStub<ICalculateFee>(); FeeCalculationRepo.Stub(r=>r.GetFee(UserTypes.Company, ItemTypes.Auction, 100, DateTime.Today, GetDiscountValueRepo)).Return(100); }
public void TestInitialize() { GetDiscountValueRepo = MockRepository.GenerateStub<IGetDiscountValue>(); FeeCalculationRepo = MockRepository.GenerateStub<ICalculateFee>(); GetDiscountValueRepo.Stub(r => r.GetItemFee((ItemTypes)1)). Throw(new Exception("No ItemTypes found")); GetDiscountValueRepo.Stub(r => r.GetUsertypeDiscount((UserTypes)1)). Throw(new Exception("No UserTypes found")); GetDiscountValueRepo.Stub(r => r.GetEndDateDiscount((ItemTypes)1, DateTime.Today)). Throw(new Exception("No ItemTypes found")); FeeCalculationRepo.Stub(r => r.GetFee((UserTypes)1, ItemTypes.Auction, 50, DateTime.Today, null)).Throw(new Exception("Invalid input")); }
public int GetFee(UserTypes usertype, ItemTypes itemtype, int itemprice, DateTime itemenddate, IGetDiscountValue iGetDiscountValue) { if (itemprice <= 0) { throw new Exception("Itemprice can not be negetive"); } try { var itemTypeDiscount = iGetDiscountValue.GetItemFee(itemtype); var userdiscount = iGetDiscountValue.GetUsertypeDiscount(usertype); var enddatediscount = iGetDiscountValue.GetEndDateDiscount(itemtype, itemenddate); return itemprice + itemTypeDiscount - (userdiscount + enddatediscount); } catch { throw new Exception("Invalid input"); } }
public ProgramErrorTests() { GetDiscountValue = new GetDiscountValues(); Calculatefee = new CalculateFee(); }