Beispiel #1
0
        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));
        }
Beispiel #2
0
        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+"));
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }