Esempio n. 1
0
        public async Task GetReviewDetailsTest_Success()
        {
            //Arrange
            var httpClient = SetupMock();

            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var id = 1;

                //Act
                var result = await controller.Details(id);

                //Assert
                var objResult = result.Result as OkObjectResult;
                Assert.IsNotNull(objResult);
                var retResult = objResult.Value as ReviewDetailsDto;
                Assert.IsNotNull(retResult);

                Assert.AreEqual(TestData.Reviews()[id - 1].Id, retResult.Id);
                Assert.AreEqual(TestData.Reviews()[id - 1].PurchaseId, retResult.PurchaseId);
                Assert.AreEqual(TestData.Reviews()[id - 1].IsVisible, retResult.IsVisible);
                Assert.AreEqual(TestData.Reviews()[id - 1].Rating, retResult.Rating);
                Assert.AreEqual(TestData.Reviews()[id - 1].Content, retResult.Content);
            }
        }
        public void Details([Frozen] Mock <IReviewRepository> reviewRepository, [Frozen] Mock <IPaginationHandler <Review, ReviewSortOrder> > paginationHandler)
        {
            var sut = new ReviewsController(reviewRepository.Object, paginationHandler.Object);

            // Act
            ViewResult result = sut.Details(15) as ViewResult;

            // Assert
            Assert.NotNull(result);
        }
        public void DetailsTest()
        {
            //Arrange
            ReviewsController reviewsController = new ReviewsController();
            //Act
            var result = reviewsController.Details(2);

            //Assert
            Assert.IsNotNull(result);
        }
Esempio n. 4
0
        public void Controller_GetViewResultDetails_IActionResult()
        {
            //Arrange
            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);

            //Act
            var result = controller.Details(1);

            //Assert
            Assert.IsInstanceOfType(result, typeof(Task <IActionResult>));
        }
        public void TestReviewsDetails()
        {
            //Arrange
            FakeRestaurantRepository fakeRestaurantRepository = new FakeRestaurantRepository();
            FakeReviewRepository     fakeReviewRepository     = new FakeReviewRepository();
            ReviewsController        controller = new ReviewsController(fakeRestaurantRepository, fakeReviewRepository);

            //Act
            var result = controller.Details(1) as ViewResult;
            var data   = result.Model as Review;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("A", data.ReviewerName);
        }
Esempio n. 6
0
        public async Task GetReviewDetailsTestAsync_Hidden()
        {
            //Arrange
            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var id = 2;

                //Act
                var result = await controller.Details(id);

                //Assert
                Assert.IsInstanceOfType(result.Result, typeof(NotFoundResult));
            }
        }
Esempio n. 7
0
        public void Mock_ReviewGetDetails_ReturnsView()
        {
            //arrange
            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);
            Review            testReview = new Review {
                ReviewId = 1, Author = "Bob", ContentBody = "This product is great", Rating = 5
            };

            //act
            var resultView = controller.Details(testReview.ReviewId) as ViewResult;
            var model      = resultView.ViewData.Model as Review;

            //assert
            Assert.IsInstanceOfType(resultView, typeof(ViewResult));
            Assert.IsInstanceOfType(model, typeof(Review));
        }
Esempio n. 8
0
        public async Task DeleteReviewTest()
        {
            // Arrange
            var repo         = new FakeReviewRepository(TestData.Reviews());
            var purchaseRepo = new FakePurchaseService(TestData.Purchases());

            using (var controller = new ReviewsController(repo, purchaseRepo, new NullLogger <ReviewsController>()))
            {
                var reviewId = 1;

                // Act
                await controller.DeleteConfirmed(reviewId);

                var review = await controller.Details(reviewId);

                // Assert
                Assert.IsInstanceOfType(review.Result, typeof(NotFoundResult));
            }
        }
        public void Mock_GetDetails_ReturnsView()
        {
            // Arrange
            Product testProduct = new Product
            {
                ProductId = 1,
                Name      = "Wash the dog"
            };

            DbSetup2();
            ReviewsController controller = new ReviewsController(mock.Object);

            // Act
            var resultView = controller.Details(testProduct.ProductId) as ViewResult;
            var model      = resultView.ViewData.Model as Product;

            // Assert
            Assert.IsInstanceOfType(resultView, typeof(ViewResult));
            Assert.IsInstanceOfType(model, typeof(Product));
        }
Esempio n. 10
0
        public void Mock_GetDetails_ReturnsView()
        {
            // Arrange
            Review testReview = new Review
            {
                ReviewId = 4,
                Author   = "Darwin"
            };

            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);

            // Act
            var resultView = controller.Details(testReview.ReviewId) as ViewResult;
            var model      = resultView.ViewData.Model as Review;

            // Assert
            Assert.IsInstanceOfType(resultView, typeof(ViewResult));
            Assert.IsInstanceOfType(model, typeof(Review));
        }
        public void Mock_GetDetails_ReturnsView()
        {
            // Arrange
            Review testReview = new Review
            {
                ReviewId    = 1,
                Author      = "Joey Chompers",
                ContentBody = "Great gummis, love them!",
                Rating      = 5
            };

            DbSetup();
            ReviewsController controller = new ReviewsController(mock.Object);

            // Act
            var resultView = controller.Details(testReview.ReviewId) as ViewResult;
            var model      = resultView.ViewData.Model as Review;

            // Assert
            Assert.IsInstanceOfType(resultView, typeof(ViewResult));
            Assert.IsInstanceOfType(model, typeof(Review));
        }
Esempio n. 12
0
        public void Details_Returns_A_View()
        {
            var result = underTest.Details(1);

            Assert.IsType <ViewResult>(result);
        }