Example #1
0
        public async Task AddDishItem()
        {
            var context = new FoodOrderContext().CreateDbContext(null);
            var repo    = new FoodOrderRepository(context);
            var date    = DateTime.Now;

            var dishItem = new DishItem
            {
                Name     = "Salo",
                Price    = 100,
                Category = new DishCategory
                {
                    Name = "Еда богов"
                },
                Supplier    = repo.All <Supplier>().FirstOrDefault(x => x.Name == "ГлаголЪ"),
                AvailableOn = new List <DishItemToWeekDay> {
                    new DishItemToWeekDay {
                        WeekDay = repo.GetById <WeekDay>(1)
                    }
                },
                AvailableUntil = date
            };

            await repo.InsertAsync(dishItem);

            await repo.SaveAsync();

            var i = repo.All <DishItem>().Include(x => x.AvailableOn).FirstOrDefault(x => x.AvailableUntil == date);

            Assert.Equal(dishItem.AvailableOn.First().DishItemId, i.AvailableOn.First().DishItemId);
            Assert.Equal(dishItem.AvailableOn.First().WeekDayId, i.AvailableOn.First().WeekDayId);
        }