Exemplo n.º 1
0
            public void TestCreateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo = new ServingBusinessObject();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var serving = new Serving(menu.Id, course.Id, dish.Id);

                var resCreate = sbo.CreateAsync(serving).Result;
                var resGet    = sbo.ReadAsync(serving.Id).Result;

                Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
            }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void TestListMenuAsync()
        {
            RestaurantSeeder.Seed();
            var bo      = new MenuBusinessObject();
            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count > 0);
        }
Exemplo n.º 4
0
        public void TestListMenuAsync()
        {
            ContextSeeders.Seed();
            var bo      = new MenuBusinessObject();
            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        public void TestDeleteMenuAsync()
        {
            ContextSeeders.Seed();
            var bo = new MenuBusinessObject();

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

            resList = bo.ListAsync().Result;

            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public void TestCreateAndListMenuAsync()
        {
            RestaurantSeeder.Seed();
            var mbo  = new MealBusinessObject();
            var rbo  = new RestaurantBusinessObject();
            var mebo = new MenuBusinessObject();

            var m = mbo.ListAsync().Result.Result.First();
            var r = rbo.ListAsync().Result.Result.First();

            var dr        = new Menu(DateTime.Now, r.Id, m.Id);
            var resCreate = mebo.CreateAsync(dr).Result;
            var resGet    = mebo.ReadAsync(dr.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Exemplo n.º 10
0
        public void TestCreateAndListServingAsync()
        {
            RestaurantSeeder.Seed();
            var cbo = new CourseBusinessObject();
            var dbo = new DishBusinessObject();
            var mbo = new MenuBusinessObject();
            var sbo = new ServingBusinessObject();

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

            var dr        = new Serving(m.Id, d.Id, c.Id);
            var resCreate = sbo.CreateAsync(dr).Result;
            var resGet    = sbo.ReadAsync(dr.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Exemplo n.º 11
0
            public void TestUpdateServingAsync()
            {
                ContextSeeders.Seed();
                var sbo     = new ServingBusinessObject();
                var resList = sbo.List();
                var item    = resList.Result.FirstOrDefault();

                var rbo    = new RestaurantBusinessObject();
                var mealbo = new MealBusinessObject();
                var drbo   = new DietaryRestrictionBusinessObject();
                var mbo    = new MenuBusinessObject();
                var cbo    = new CourseBusinessObject();
                var dbo    = new DishBusinessObject();

                var restaurant = new Restaurant("a", "b", "c", "d", "f", 6);
                var meal       = new Meal("a", "b", "c");
                var dr         = new DietaryRestriction("ok");
                var menu       = new Menu(DateTime.Now, restaurant.Id, meal.Id);
                var course     = new Course("yes");
                var dish       = new Dish("uh", dr.Id);

                rbo.Create(restaurant);
                mealbo.Create(meal);
                drbo.Create(dr);
                mbo.Create(menu);
                cbo.Create(course);
                dbo.Create(dish);

                var newServing = new Serving(menu.Id, course.Id, dish.Id);

                item.MenuId   = newServing.MenuId;
                item.CourseId = newServing.CourseId;
                item.DishId   = newServing.DishId;

                var resUpdate = sbo.UpdateAsync(item).Result;

                resList = sbo.ListAsync().Result;

                Assert.IsTrue(resList.Success && resUpdate.Success &&
                              resList.Result.First().MenuId == newServing.MenuId && resList.Result.First().CourseId == newServing.CourseId &&
                              resList.Result.First().DishId == newServing.DishId);
            }
Exemplo n.º 12
0
        public void TestCreateMenuAsync()
        {
            ContextSeeders.Seed();
            var mbo = new MenuBusinessObject();

            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 menu = new Menu(DateTime.Now, restaurant.Id, meal.Id);

            var resCreate = mbo.CreateAsync(menu).Result;
            var resGet    = mbo.ReadAsync(menu.Id).Result;

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