Пример #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);
        }
        public void FillDatabaseWithUsers()
        {
            var context = new FoodOrderDbContext().CreateDbContext(null);
            var repo    = new FoodOrderRepository(context);

            var prevCount = repo.All <User>().Count();

            repo.InsertAsync(
                new[] {
                new User {
                    Email    = "*****@*****.**",
                    UserName = "******"
                },
                new User {
                    Email    = "*****@*****.**",
                    UserName = "******"
                },
                new User {
                    Email    = "*****@*****.**",
                    UserName = "******"
                },
                new User {
                    Email    = "*****@*****.**",
                    UserName = "******"
                }
            });
            repo.Save();
            var currentCount = repo.All <User>().Count();
            var diff         = currentCount - prevCount;

            Assert.Equal(4, diff);
        }