public void GetShoesPairTest() { ShoesPair shoesPair = new ShoesPair(dataService.GetShoes(111), new decimal(300.0), new decimal(0.22), 20, new decimal(0.1)); Assert.AreEqual(shoesPair, dataService.GetShoesPair(0)); }
public void ReturnShoes(ShoesPair shoesPair, Transaction invoice) { Transaction ret = new Return(invoice.Client, invoice.ShoesPair, invoice.Count); dataRepository.DeleteTransaction(invoice); dataRepository.AddTransaction(ret); dataRepository.IncreaseStockCount(shoesPair, ret); }
public void TransactionTest() { Client client = new Client("Jan", "Kowalski", "*****@*****.**", "Pabianice Zamkowa 23b", "+48123456789"); Shoes shoes = new Shoes("XC89", 39, "Adidas", Shoes.SexEnum.Female); ShoesPair shoesPair = new ShoesPair(shoes, new decimal(300.0), new decimal(0.22), 20, new decimal(0.1)); Transaction invoice = new Invoice(client, shoesPair, 1, new decimal(12.0)); Assert.AreEqual(client, invoice.Client); Assert.AreEqual(shoesPair, invoice.ShoesPair); Assert.AreEqual(1, invoice.Count); }
public void ShoesPairTest() { Shoes shoes = new Shoes("XC89", 39, "Adidas", Shoes.SexEnum.Female); ShoesPair shoesPair = new ShoesPair(shoes, new decimal(300.0), new decimal(0.22), 20, new decimal(0.1)); Assert.AreEqual(shoes, shoesPair.Shoes); Assert.AreEqual(new decimal(300.0), shoesPair.NettoPrice); Assert.AreEqual(new decimal(0.22), shoesPair.Tax); Assert.AreEqual(20, shoesPair.StockCount); Assert.AreEqual(new decimal(0.1), shoesPair.Discount); }
public void GetShoesPairTest() { // valid argument ShoesPair shoesPair = new ShoesPair(dataRepository.GetShoes(111), new decimal(300.0), new decimal(0.22), 20, new decimal(0.1)); Assert.AreEqual(shoesPair, dataRepository.GetShoesPair(0)); // argument exception Assert.ThrowsException <ArgumentException>(() => dataRepository.GetShoesPair(1111)); }
public void CreateShoesPairTest() { Shoes shoes = randomFiller.CreateShoes(); ShoesPair created = randomFiller.CreateShoesPair(shoes); Assert.IsTrue(created.Discount <= new decimal(0.75) && created.Discount >= new decimal(0.0)); Assert.IsTrue(created.NettoPrice <= new decimal(500) && created.NettoPrice >= new decimal(50)); Assert.IsFalse(created.Shoes == null); Assert.IsTrue(created.StockCount >= 10 && created.StockCount <= 1000); Assert.AreEqual(created.Tax, new decimal(0.22)); }
public void CreateInvoiceTest() { Shoes shoes = randomFiller.CreateShoes(); ShoesPair shoesPair = randomFiller.CreateShoesPair(shoes); Client client = randomFiller.CreateClient(); Transaction created = randomFiller.CreateInvoice(client, shoesPair); Assert.IsFalse(created.Client == null); Assert.IsFalse(created.ShoesPair == null); Assert.AreEqual(created.Count, 1); Assert.IsFalse(created.Date == null); }
// create invoice public void BuyShoes(Client client, ShoesPair shoesPair, int count, decimal shippingCost) { if (dataRepository.IsShoesPairAvailable(shoesPair, count)) { Transaction invoice = new Invoice(client, shoesPair, count, shippingCost); dataRepository.DecreaseStockCount(shoesPair, invoice); dataRepository.AddTransaction(invoice); } else { throw new ArgumentException($"No such number of pairs in stock. Current number in stock: {shoesPair.StockCount}"); } }
public void UpdateShoesPairTest() { // valid argument ShoesPair shoesPair = new ShoesPair(dataRepository.GetShoes(111), new decimal(300.0), new decimal(0.22), 30, new decimal(0.1)); dataRepository.UpdateShoesPair(0, shoesPair); Assert.AreEqual(30, dataRepository.GetShoesPair(0).StockCount); // argument exception Assert.ThrowsException <ArgumentException>(() => dataRepository.UpdateShoesPair(1111, shoesPair)); }
public void AddShoesPairTest() { // valid argument ShoesPair shoesPair1 = new ShoesPair(dataRepository.GetShoes(114), new decimal(450.0), new decimal(0.22), 10, new decimal(0.2)); dataRepository.AddShoesPair(shoesPair1); Assert.AreEqual(7, dataRepository.GetAllShoesPairs().Count()); Assert.AreEqual(shoesPair1, dataRepository.GetAllShoesPairs().Last()); // argument exception ShoesPair shoesPair2 = new ShoesPair(dataRepository.GetShoes(111), new decimal(300.0), new decimal(0.22), 20, new decimal(0.1)); Assert.ThrowsException <ArgumentException>(() => dataRepository.AddShoesPair(shoesPair2)); }
public void AddShoesPair(Shoes shoes, decimal nettoPrice, decimal tax, int stockCount, decimal discount) { ShoesPair shoesPair = new ShoesPair(shoes, nettoPrice, tax, stockCount, discount); dataRepository.AddShoesPair(shoesPair); }