public void ViewRestaurant_ValidIDNoReviews_Succeed()
        {
            var viewingUserId        = 1;
            var viewingRestID        = 1;
            var expectedRequestModel = SetupExpectedRequest(viewingUserId, viewingRestID);

            var expectedName          = "Restaurant name one";
            var expectedCuisine       = Cuisines[0];
            var expectedRestId        = 1;
            var expectedReviews       = Enumerable.Empty <Review>();
            var expectedAverageRating = 0;
            var expectedReviewCount   = 0;
            var expectedSucessStatus  = true;
            var expectedResponse      = SetupExpectedResponse(expectedSucessStatus, expectedName,
                                                              expectedCuisine, expectedRestId, expectedReviews, expectedAverageRating, expectedReviewCount);


            var viewRestTran = new ViewRestaurantTransaction(Repo, Log, expectedRequestModel);

            viewRestTran.Execute();
            var actualResponse = viewRestTran.Response;

            //assert
            Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status");
            Assert.AreEqual(expectedResponse, actualResponse, "Invalid response");

            ValidateRestaurant(expectedRestId, expectedName, expectedCuisine, expectedReviews, expectedAverageRating, expectedReviewCount);
        }
        public void ViewRestaurant_InvalidID_Fail()
        {
            var viewingUserId        = 1;
            var viewingRestID        = 20;
            var expectedRequestModel = SetupExpectedRequest(viewingUserId, viewingRestID);

            var viewRestTran = new ViewRestaurantTransaction(Repo, Log, expectedRequestModel);

            viewRestTran.Execute();
            var actualResponse = viewRestTran.Response;

            //assert
            Assert.AreEqual(false, actualResponse.WasSucessfull, "Invalid execution status");
        }
        public void ViewRestaurant_ValidIDTwoReviews_Succeed()
        {
            var viewingUserId        = 1;
            var viewingRestID        = 3;
            var expectedRequestModel = SetupExpectedRequest(viewingUserId, viewingRestID);

            var expectedName          = "Restaurant name Three";
            var expectedCuisine       = Cuisines[1];
            var expectedRestId        = 3;
            var expectedAverageRating = 4;
            var expectedReviewCount   = 2;
            var expectedReviews       = new List <Review>()
            {
                new Review
                {
                    Comment        = "First Comment for 3",
                    Rating         = 3,
                    PostedDateTime = new DateTime(2016, 10, 16),
                    ReviewNumber   = 2,
                    ReviewUser     = Users[3]
                },
                new Review
                {
                    Comment        = "Second Comment for 3",
                    Rating         = 5,
                    PostedDateTime = new DateTime(2016, 10, 10),
                    ReviewNumber   = 3,
                    ReviewUser     = Users[2]
                }
            };

            var expectedSucessStatus = true;
            var expectedResponse     = SetupExpectedResponse(expectedSucessStatus, expectedName,
                                                             expectedCuisine, expectedRestId, expectedReviews, expectedAverageRating, expectedReviewCount);


            var viewRestTran = new ViewRestaurantTransaction(Repo, Log, expectedRequestModel);

            viewRestTran.Execute();
            var actualResponse = viewRestTran.Response;

            //assert
            Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status");
            Assert.AreEqual(expectedResponse, actualResponse, "Invalid response");

            ValidateRestaurant(expectedRestId, expectedName, expectedCuisine, expectedReviews, expectedAverageRating,
                               expectedReviewCount);
        }
        public void ViewRestaurant_ValidIdTenReviews_Succeed()
        {
            var viewingUserId        = 2;
            var viewingRestID        = 4;
            var expectedRequestModel = SetupExpectedRequest(viewingUserId, viewingRestID);

            var expectedName          = "Restaurant name Four";
            var expectedCuisine       = Cuisines[1];
            var expectedRestId        = 4;
            var expectedAverageRating = 3;
            var expectedReviewCount   = 10;
            var expectedReviews       = new List <Review>();

            //restaurant 4 setup
            for (var i = 0; i < 10; i++)
            {
                var newReview = new Review
                {
                    CreatedBy      = Users[i].Id,
                    UpdatedBy      = Users[i].Id,
                    Comment        = $"Comment {i} for Restaurant 4",
                    Rating         = (i % 5) + 1,
                    PostedDateTime = new DateTime(2016, 09, i + 1),
                    ReviewNumber   = 4 + i,
                    ReviewUser     = Users[i]
                };
                // 0+1 to 4+1

                expectedReviews.Add(newReview);
            }

            var expectedSucessStatus = true;
            var expectedResponse     = SetupExpectedResponse(expectedSucessStatus, expectedName,
                                                             expectedCuisine, expectedRestId, expectedReviews, expectedAverageRating, expectedReviewCount);

            var viewRestTran = new ViewRestaurantTransaction(Repo, Log, expectedRequestModel);

            viewRestTran.Execute();
            var actualResponse = viewRestTran.Response;

            //assert
            Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status");
            Assert.AreEqual(expectedResponse, actualResponse, "Invalid response");

            ValidateRestaurant(expectedRestId, expectedName, expectedCuisine, expectedReviews, expectedAverageRating,
                               expectedReviewCount);
        }
        public void ViewRestaurant_ValidIDOneReviews_Succeed()
        {
            var viewingUserId        = 1;
            var viewingRestID        = 2;
            var expectedRequestModel = SetupExpectedRequest(viewingUserId, viewingRestID);

            var expectedName          = "Restaurant name Two";
            var expectedCuisine       = Cuisines[0];
            var expectedRestId        = 2;
            var expectedAverageRating = 3;
            var expectedReviewCount   = 1;
            var expectedReviews       = new List <Review>()
            {
                new Review
                {
                    Comment        = "Comment for 2",
                    Rating         = 3,
                    PostedDateTime = new DateTime(2016, 10, 16),
                    ReviewNumber   = 1,
                    ReviewUser     = Users[2]
                }
            };

            //TODO: review response to check if the values can be updated (they should not be able to)
            var expectedSucessStatus = true;
            var expectedResponse     = SetupExpectedResponse(expectedSucessStatus, expectedName,
                                                             expectedCuisine, expectedRestId, expectedReviews, expectedAverageRating, expectedReviewCount);

            var viewRestTran = new ViewRestaurantTransaction(Repo, Log, expectedRequestModel);

            viewRestTran.Execute();
            var actualResponse = viewRestTran.Response;

            //assert
            Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status");
            Assert.AreEqual(expectedResponse, actualResponse, "Invalid response");

            ValidateRestaurant(expectedRestId, expectedName, expectedCuisine, expectedReviews, expectedAverageRating,
                               expectedReviewCount);
        }