Ejemplo n.º 1
0
        public void GetRestaurantsOnCuisineId_NoRestaurnats_Empty()
        {
            //arrange
            var expectedResponse = new API.ViewModels.Restaurant[] { };

            var repoResonse             = new Restaurant[] { };
            var cuisineId               = 5;
            var expectedCollectionCount = 0;

            MockRepository.Setup(m => m.DoseCuisineIdExist(cuisineId)).Returns(true);
            MockRepository.Setup(m => m.GetRestaurantForCuisine(cuisineId)).Returns(repoResonse);
            MockIdentity.Setup(m => m.GetRequestingUserId()).Returns(10);

            var ctrl = new CuisinesController(MockRepository.Object, MockLogger.Object, MockIdentity.Object);

            //act
            var actionResult  = ctrl.Get(cuisineId);
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <API.ViewModels.Restaurant> >;


            //assert
            Assert.IsNotNull(contentResult, "Ok-200 status was not returned");
            Assert.IsNotNull(contentResult.Content, "No content was returned");
            RestaurantsControllerTests.ValidateRestaurantCollectionResponse(contentResult.Content, expectedResponse, expectedCollectionCount);
        }
Ejemplo n.º 2
0
        public void GetRestaurantsOnCuisineId_OneRestaurnat_OK()
        {
            //arrange
            var expectedRestID          = 1234;
            var cuisineName             = "Mexican";
            var cuisineId               = 10;
            var restName                = "No1 Mexican Restaurant";
            var createdUser             = 10;
            var expectedCollectionCount = 1;
            var cuisine = new Cuisine
            {
                Name      = cuisineName,
                Id        = cuisineId,
                CreatedBy = createdUser,
                UpdatedBy = createdUser
            };

            var expectedResponse = new[]
            {
                new API.ViewModels.Restaurant {
                    Id            = expectedRestID,
                    AverageRating = 0,
                    CuisineName   = cuisineName,
                    CuisineId     = cuisineId,
                    Name          = restName,
                    ReviewCount   = 0
                }
            };

            var repoResonse = new[]
            {
                new Restaurant
                {
                    Id        = expectedRestID,
                    CreatedBy = createdUser,
                    UpdatedBy = createdUser,
                    Cuisine   = cuisine,
                    Name      = restName
                }
            };

            MockRepository.Setup(m => m.DoseCuisineIdExist(cuisineId)).Returns(true);
            MockRepository.Setup(m => m.GetRestaurantForCuisine(cuisineId)).Returns(repoResonse);
            MockIdentity.Setup(m => m.GetRequestingUserId()).Returns(10);

            var ctrl = new CuisinesController(MockRepository.Object, MockLogger.Object, MockIdentity.Object);


            //act
            var actionResult  = ctrl.Get(cuisineId);
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <API.ViewModels.Restaurant> >;

            //assert
            Assert.IsNotNull(contentResult, "Ok-200 status was not returned");
            Assert.IsNotNull(contentResult.Content, "No content was returned");
            RestaurantsControllerTests.ValidateRestaurantCollectionResponse(contentResult.Content, expectedResponse, expectedCollectionCount);
        }