public void GetBasketsByUserId_Should_Return_New_List_When_Not_Found()
        {
            //Arrange
            var mock = new Mock <IBasketRepository>();

            mock.Setup(x => x.GetBasketsByUserId("36")).Returns(new List <BasketDTO>());
            BasketUC target = new BasketUC(mock.Object);

            //Act
            var result = target.GetBasketsByUserId("36").ToList();

            //Assert
            Assert.AreEqual(result.Count, 0);
        }
Ejemplo n.º 2
0
        public IActionResult GetBasketsByUserId()
        {
            var          result  = basketUC.GetBasketsByUserId(User.FindFirst(ClaimTypes.NameIdentifier).Value).ToList();
            RestaurantUC restoUC = new RestaurantUC(restoRepository);

            foreach (var item in result)
            {
                foreach (var shoppingMeal in item.ShoppingMeals)
                {
                    shoppingMeal.Meal.MealType            = mealTypeUC.GetMealTypeById(shoppingMeal.Meal.MealTypeID);
                    shoppingMeal.Meal.MealType.Restaurant = restoUC.GetRestaurantById(shoppingMeal.Meal.MealType.RestaurantId);
                }
            }
            result = result.OrderBy(x => x.ArrivalDate).ToList();
            return(View(result));
        }
        public void GetBasketsByUserId_Should_Return_Proper_Collection()
        {
            //Arrange
            var mock      = new Mock <IBasketRepository>();
            var myBaskets = new List <BasketDTO>
            {
                new BasketDTO
                {
                    Id     = 2,
                    UserId = "36"
                }
            };

            mock.Setup(x => x.GetBasketsByUserId("36")).Returns(myBaskets);
            BasketUC target = new BasketUC(mock.Object);

            //Act
            var result = target.GetBasketsByUserId("36").ToList();

            //Assert
            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result[0].Id, 2);
        }