예제 #1
0
        public void TestUpdateMenu()
        {
            ContextSeeders.Seed();
            var mbo     = new MenuBusinessObject();
            var resList = mbo.List();
            var item    = resList.Result.FirstOrDefault();

            var rbo    = new RestaurantBusinessObject();
            var mealbo = new MealBusinessObject();

            var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
            var meal       = new Meal("a", "b", "c");

            rbo.Create(restaurant);
            mealbo.Create(meal);

            var newMenu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            item.Date         = newMenu.Date;
            item.RestaurantId = newMenu.RestaurantId;
            item.MealId       = newMenu.MealId;

            var resUpdate = mbo.Update(item);

            resList = mbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Date == newMenu.Date && resList.Result.First().RestaurantId == newMenu.RestaurantId &&
                          resList.Result.First().MealId == newMenu.MealId);
        }
예제 #2
0
        public void TestDeleteMenu()
        {
            ContextSeeders.Seed();
            var bo = new MenuBusinessObject();

            var resList   = bo.List();
            var resDelete = bo.Delete(resList.Result.First().Id);

            resList = bo.List();

            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
예제 #3
0
        public void TestListMenu()
        {
            RestaurantSeeder.Seed();
            var bo      = new MenuBusinessObject();
            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count > 0);
        }
예제 #4
0
        public void TestListMenu()
        {
            ContextSeeders.Seed();
            var bo      = new MenuBusinessObject();
            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
예제 #5
0
        public void TestDeleteMenu()
        {
            RestaurantSeeder.Seed();
            var bo        = new MenuBusinessObject();
            var resList   = bo.List();
            var total     = resList.Result.Count;
            var resDelete = bo.Delete(resList.Result.First().Id);

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == total - 1);
        }
예제 #6
0
        public void TestUpdateMenu()
        {
            RestaurantSeeder.Seed();
            var bo      = new MenuBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();
            var now     = DateTime.Now;

            item.Date = now;
            var resUpdate = bo.Update(item);

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Date == now);
        }
예제 #7
0
        public void TestUpdateServing()
        {
            RestaurantSeeder.Seed();
            var bo        = new ServingBusinessObject();
            var mbo       = new MenuBusinessObject();
            var resList   = bo.List();
            var item      = resList.Result.FirstOrDefault();
            var newMenuId = mbo.List().Result.First(x => x.Id != item.MenuId).Id;

            item.MenuId = newMenuId;
            var resUpdate = bo.Update(item);

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().MenuId == newMenuId);
        }
예제 #8
0
        public ActionResult <List <MenuViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var list = new List <MenuViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(MenuViewModel.Parse(item));
            }
            return(list);
        }
예제 #9
0
        public void TestCreateAndListServing()
        {
            RestaurantSeeder.Seed();
            var cbo = new CourseBusinessObject();
            var dbo = new DishBusinessObject();
            var mbo = new MenuBusinessObject();
            var sbo = new ServingBusinessObject();

            var c = cbo.List().Result.First();
            var d = dbo.List().Result.First();
            var m = mbo.List().Result.First();

            var dr        = new Serving(m.Id, d.Id, c.Id);
            var resCreate = sbo.Create(dr);
            var resGet    = sbo.Read(dr.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }