public void PriceTest() { StockKeepingUnits target = new StockKeepingUnits(); // TODO: Initialize to an appropriate value target.Add(new StockKeepingUnit("Wheel", 88.50)); target.Add(new StockKeepingUnit("Tyre", 50.00)); target.Add(new StockKeepingUnit("Tyrehorn", 11.50)); double expected = 150.00F; // TODO: Initialize to an appropriate value double actual; actual = target.Price(); Assert.AreEqual(expected, actual); }
/// <summary> /// /// </summary> public Receipt CalculateReceipt(string[] items) { Receipt result = new Receipt(); //zero the result StockKeepingUnits itemSKUs = new StockKeepingUnits(); foreach (var s in items) { StockKeepingUnit tempRef = fSKUs.FindSingletonSKU(s); if (tempRef != null) { itemSKUs.Add(new StockKeepingUnit(tempRef)); } else { result.AddRemark(String.Format("\"{0}\" was not recognised and skipped", s)); } } result.AddRemark(itemSKUs.ToString()); //now that we know what we are buting, we should apply the discounts result.Subtotal = itemSKUs.Price(); DiscountResults discountResults = fDiscounts.ApplyDiscounts(itemSKUs); result.Total = result.Subtotal - discountResults.Sum(); result.AddDiscount(discountResults.ToString()); return(result); }
public void FindSKUTest_VerifyByPrice() { StockKeepingUnits target = new StockKeepingUnits(); // TODO: Initialize to an appropriate value StockKeepingUnit wheel = new StockKeepingUnit("Wheel", 88.50); target.Add(wheel); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyre", 50.00)); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyrehorn", 11.50)); target.Add(wheel); string skuname = wheel.Name; // TODO: Initialize to an appropriate value //as we are not always returning the SAME instance, testing that would be pointless. StockKeepingUnit expected = new StockKeepingUnit(wheel); // TODO: Initialize to an appropriate value //we have enfourced a limit that the FindSKU will return null when there is 0 or > 1 SKU //in the list. StockKeepingUnit actual; actual = target.FindSKU(skuname); Assert.IsNotNull(actual, "There was no 'actual' item instance found"); Assert.AreEqual <double>(expected.Price, actual.Price, string.Format("L: {0} - R: {1}", expected.Price, actual.Price)); }
public void FindSKUTest_VerifyByName() { StockKeepingUnits target = new StockKeepingUnits(); // TODO: Initialize to an appropriate value StockKeepingUnit wheel = new StockKeepingUnit("Wheel", 88.50); target.Add(wheel); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyre", 50.00)); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyrehorn", 11.50)); target.Add(wheel); string skuname = wheel.Name; // TODO: Initialize to an appropriate value //as we are not always returning the SAME instance, testing that would be pointless. StockKeepingUnit expected = new StockKeepingUnit(wheel); // TODO: Initialize to an appropriate value StockKeepingUnit actual; actual = target.FindSKU(skuname); Assert.AreEqual <string>(expected.Name, actual.Name); }
public void FindSKUsTest_VerifyWheelsCanBeFound() { StockKeepingUnits target = new StockKeepingUnits(); // TODO: Initialize to an appropriate value StockKeepingUnit wheel = new StockKeepingUnit("Wheel", 88.50); target.Add(wheel); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyre", 50.00)); target.Add(new StockKeepingUnit(wheel)); //because, we don't just use the same instance target.Add(new StockKeepingUnit("Tyrehorn", 11.50)); target.Add(wheel); string skuname = wheel.Name; // TODO: Initialize to an appropriate value StockKeepingUnits expected = new StockKeepingUnits(new StockKeepingUnit[] { new StockKeepingUnit(wheel), wheel, wheel, new StockKeepingUnit(wheel) }); // TODO: Initialize to an appropriate value StockKeepingUnits actual; actual = target.FindSKUs(skuname); Assert.AreEqual(expected.Count, actual.Count); }
/// <summary> /// Adds a new SKU item /// </summary> public void AddSKU(StockKeepingUnit item) { fSKUs.Add(item); }