public void FindMethod_Returns_ProductOnGivenIndexIfExists() { productStock.Add(new Product("bb", 1, 1)); productStock.Add(new Product("bsaads", 2, 1)); var productIndex0 = productStock.Find(0); var productIndex1 = productStock.Find(1); Assert.AreEqual(productIndex0, productStock[0]); Assert.AreEqual(productIndex1, productStock[1]); }
public void ProductStock_FindMethodReturnsCorrectElement(int index, string name) { var stock = new ProductStock(); stock.Add(new Product("SSD", 12.4m, 3)); stock.Add(new Product("SSD", 12.4m, 3)); stock.Add(new Product("HDD", 12.4m, 3)); stock.Add(new Product("RAM", 12.4m, 3)); Assert.AreEqual(stock.Find(index).CompareTo(new Product(name, 12.4m, 3)), 0); }
public void ProductStock_FindMethodThrowsExceptionWhenSearchingWithInvalidIndex(int index) { var stock = new ProductStock(); stock.Add(new Product("SSD", 12.4m, 3)); stock.Add(new Product("SSD", 12.4m, 3)); stock.Add(new Product("HDD", 12.4m, 3)); Assert.Throws <IndexOutOfRangeException>(() => stock.Find(index)); }
public void Find_AtInvalidIndexShouldThrowIndexOutOfRangeException() { Assert.Throws <IndexOutOfRangeException>(() => productStock.Find(22)); }