Exemplo n.º 1
0
        public async Task GetMyRestaurant_RestaurantNotAvailable_UserIsRestaurantOwner()
        {
            //Arrange
            int    restaurantId = 1;
            var    expectedRestaurantDetails = helper.GetRestaurantDetailsDto();
            string userId = "475c5e32-049c-4d7b-a963-02ebdc15a94b";

            var foodRepository       = new Mock <IFoodRepository>();
            var restaurantRepository = new Mock <IRestaurantRepository>();

            restaurantRepository.Setup(r => r.IsRestaurantAvailableForUsers(restaurantId))
            .ReturnsAsync(false);
            restaurantRepository.Setup(r => r.GetRestaurantDetails(restaurantId))
            .ReturnsAsync(expectedRestaurantDetails);
            var userRepository = new Mock <IUserRepository>();

            userRepository.Setup(u => u.UserHasRestaurant(userId))
            .ReturnsAsync(true);
            userRepository.Setup(u => u.GetMyRestaurantId(userId))
            .ReturnsAsync(restaurantId);
            var httpContext = new Mock <IHttpContextAccessor>();

            httpContext.SetupGet(h => h.HttpContext.User)
            .Returns(helper.GetUserClaimPrinciple(userId));

            var manager = new RestaurantManager(restaurantRepository.Object, userRepository.Object, foodRepository.Object, httpContext.Object);

            //Act
            var restaurantDetails = await manager.GetMyRestaurantDetails();

            //Assert
            Assert.Equal(expectedRestaurantDetails, restaurantDetails);
        }
Exemplo n.º 2
0
 public async Task <ActionResult <RestaurantDetailsDto> > GetMyRestaurantDetails()
 {
     return(await restaurantManager.GetMyRestaurantDetails());
 }