Exemple #1
0
        public void GetAllTablesOrderedByNumberTest()
        {
            tHelper.AddNewTable(new Table {
                NumberOfSeats = 1, TableNumber = 1000
            });
            tHelper.AddNewTable(new Table {
                NumberOfSeats = 1, TableNumber = 1
            });
            var tables = tHelper.GetAllTablesOrderedByNumber().ToList();

            Assert.IsTrue(tables.First().TableNumber < tables.Last().TableNumber);
        }
Exemple #2
0
        public void SetUp()
        {
            db      = new SuperServiceContext(new DbContextOptionsBuilder().UseInMemoryDatabase(databaseName: "Fake_DB").Options);
            iHelper = new ItemHelper(db);
            tHelper = new TableHelper(db);
            oHelper = new OrderHelper(new OrderService(db), new OrderItemsService(db));
            if (oHelper.GetOrdersByTableNumber(1000).Count() > 0)
            {
                var oList = oHelper.GetOrdersByTableNumber(1000).ToList();
                foreach (var o in oList)
                {
                    oHelper.DeleteOrder(o);
                }
            }
            if (tHelper.GetTableByTableNumber(1000) != null)
            {
                tHelper.DeleteTableByTableNumber(1000);
            }
            tHelper.AddNewTable(new Table
            {
                TableNumber   = 1000,
                NumberOfSeats = 1,
            });
            table = tHelper.GetTableByTableNumber(1000);
            order = new Order {
                Table = table
            };
            if (iHelper.GetAllItemsOrderedByAvailability().FirstOrDefault() == null)
            {
                iHelper.AddNewItem(new Item {
                    Cost = 5, Name = "TestSandwich"
                }, new List <Ingredient>
                {
                    new Ingredient {
                        Name = "TestBread", Calories = 230, Carbohydrates = 15, Fat = 1, Protein = 1, Salt = 5, Sugar = 5, NumberInStock = 10
                    },
                    new Ingredient {
                        Name = "TestCheese", Calories = 150, Carbohydrates = 1, Fat = 10, Protein = 2, Salt = 5, Sugar = 3, NumberInStock = 10
                    }
                });
                iHelper.AddNewItem(new Item {
                    Cost = 8, Name = "TestStew"
                }, new List <Ingredient>
                {
                    new Ingredient {
                        Name = "TestCabbage", Calories = 60, Carbohydrates = 15, Fat = 1, Protein = 1, Salt = 5, Sugar = 5, NumberInStock = 10
                    },
                    new Ingredient {
                        Name = "TestPotatoes", Calories = 300, Carbohydrates = 60, Fat = 3, Protein = 2, Salt = 5, Sugar = 3, NumberInStock = 10
                    },
                    new Ingredient {
                        Name = "TestCarrots", Calories = 100, Carbohydrates = 20, Fat = 10, Protein = 2, Salt = 5, Sugar = 3, NumberInStock = 0
                    },
                });
            }

            items = new List <Item>
            {
                iHelper.GetAllItemsOrderedByAvailability().First(),
                    iHelper.GetAllItemsOrderedByAvailability().Last()
            };
            db.OrderStatuses.Add(new OrderStatus()
            {
                Name = "Order Placed"
            });
            db.SaveChanges();
        }