public void GetStocksTest() { var service = new StocksService(); var stock = new Equity() { Price = 50000, Quantity = 3 }; var stock1 = new Equity() { Price = 50000, Quantity = 3 }; var newStockId = service.AddStock(stock); var newStock1Id = service.AddStock(stock1); var stocks = service.GetStocks(); Assert.IsTrue(stocks.Any(s => s.Id == newStockId)); Assert.IsTrue(stocks.Any(s => s.Id == newStock1Id)); }
public void EquityNameIsGeneratedTest() { var service = new StocksService(); var stock = new Equity() { Price = 50000, Quantity = 3 }; var newStockId = service.AddStock(stock); var newStock = service.GetStock(newStockId); Assert.IsTrue(Regex.IsMatch(newStock.Name, @"Equity\d+")); }
public void EquityNameIsInctementedTest() { var service = new StocksService(); var stock = new Equity() { Price = 50000, Quantity = 3 }; var stock1 = new Equity() { Price = 50000, Quantity = 3 }; var newStockId = service.AddStock(stock); var newStock = service.GetStock(newStockId); var newStock1Id = service.AddStock(stock1); var newStock1 = service.GetStock(newStock1Id); var numericPart1 = Convert.ToInt32(Regex.Match(newStock.Name, @"\d+").Value); var numericPart2 = Convert.ToInt32(Regex.Match(newStock1.Name, @"\d+").Value); Assert.IsTrue(numericPart2 - numericPart1 == 1); }
public void AddEquityTest() { var service = new StocksService(); var stock = new Equity() { Price = 50000, Quantity = 3 }; var newStockId = service.AddStock(stock); var newStock = service.GetStock(newStockId); Assert.IsNotNull(newStock); Assert.AreEqual(stock.Price, newStock.Price); Assert.AreEqual(stock.Quantity, newStock.Quantity); }
public void DeleteEquityTest() { var service = new StocksService(); var stock = new Equity() { Price = 50000, Quantity = 3 }; var newStockId = service.AddStock(stock); var newStock = service.GetStock(newStockId); Assert.IsNotNull(newStock); service.DeleteStock(newStock.Id); newStock = service.GetStock(newStockId); Assert.IsNull(newStock); }