public void Create_Test_ValidInput()
        {
            // Arrange
            int id = bLogic.GetBreweries().LastOrDefault().BreweryID;

            // Act
            RedirectToRouteResult result = controller.Create(collection, id) as RedirectToRouteResult;

            // Assert
            Assert.AreEqual("Details", result.RouteValues["action"]);
        }
Exemplo n.º 2
0
        public void TestCreate()
        {
            //Arrange
            ReviewController controller = new ReviewController();
            string           expected   = "Reviews";

            //Act
            var    action = (RedirectToRouteResult)controller.Create(new Review());
            string actual = action.RouteValues["action"].ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void Create_Returns_A_View()
        {
            Review Model = new Review()
            {
                Content      = "test",
                ReviewerName = "test",
                Rating       = 3,
                AlbumId      = 1
            };
            var result = sut.Create(Model);

            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 4
0
        public void ReviewControllerCreateReturnsView_ExpectedSuccess()
        {
            // Arrange
            var reviews = GetReviews();
            var _mock   = new Mock <IReviewLogic>();

            _mock.Setup(x => x.GetPassengerReviews(It.IsAny <Int32>())).ReturnsAsync(reviews);
            var controllerUnderTest = new ReviewController(_context, _mock.Object);

            // Act
            var result = controllerUnderTest.Create(GetReview());

            // Assert
            var viewResult = Assert.IsType <Task <IActionResult> >(result);
        }
        public void Create_Adds_A_Model()
        {
            //Arrange
            Review model = new Review()
            {
                BevId = 1, Content = ""
            };
            //reviewRepo.GetById(1).Returns(model);

            //Act
            var result = sut.Create(model);

            //Assertion
            //Assert.Equal("You have successfully saved this course.", result.ViewData["Result"]);
            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 6
0
        public void DB_CreateNewReview_Test()
        {
            ReviewController controller = new ReviewController(db);
            Review           testReview = new Review();

            testReview.ReviewId    = 1;
            testReview.Author      = "Matt";
            testReview.ContentBody = "Best chili I've ever had!";
            testReview.Rating      = 4;
            testReview.ProductId   = 1;

            controller.Create(testReview);
            var collection = (controller.Index() as ViewResult).ViewData.Model as List <Review>;

            CollectionAssert.Contains(collection, testReview);
        }
Exemplo n.º 7
0
        public async Task CannotCreateReviewOnNonexistentStep()
        {
            // Arrange - create the mock repository
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            Step step1 = new Step {
                StepId = 1, From = "A", To = "B"
            };

            tc.Steps.Add(step1);
            // Arrange - create the controller
            ReviewController controller = new ReviewController(tc);
            // Act
            var badResult = await controller.Create(4) as ViewResult;

            // Assert
            Assert.AreEqual("CustomisedError", badResult.ViewName);
        }
Exemplo n.º 8
0
        public void DB_Edit_Test()
        {
            ReviewController controller = new ReviewController(db);
            Review           testReview = new Review();

            testReview.ReviewId    = 1;
            testReview.Author      = "Matt";
            testReview.ContentBody = "Best chili I've ever had!";
            testReview.Rating      = 4;
            testReview.ProductId   = 1;

            controller.Create(testReview);

            testReview.Author = "Matthew";
            controller.Edit(testReview);

            Assert.AreEqual("Matthew", testReview.Author);
        }
        private void BtInsertReview_Click(object sender, RoutedEventArgs e)
        {
            Review review = new Review()
            {
                ReviewID   = TransformStringIntoInt(TbReviewId.Text),
                BookID     = TransformStringIntoInt(TbBookId.Text),
                ReviewText = TbReviewText.Text
                             //Book = reviewDataGrid.ItemsSource as List<Review>
            };


            Review createdReview = reviewsController.Create(review);

            TbReviewId.Text     = createdReview.ReviewID.ToString(); //change de lb id to the real one
            TbReviewBookId.Text = createdReview.ReviewID.ToString();
            MessageBox.Show("The review with " + createdReview.ToString() + " has been created successfully.");
            LoadBooks();
        }
Exemplo n.º 10
0
        public void CreateReview()
        {
            var newReview = new ReviewCreate
            {
                AuthorName = "Rodolpho Alves",
                ReviewText = "Lorem ipsum dolor sit amet",
                Score      = 6d,
                SubjectId  = Guid.NewGuid().ToString()
            };

            _fakeRepository.Setup(m => m.Create(It.IsAny <Review>())).Returns(() =>
            {
                return(new Review
                {
                    Id = Guid.NewGuid().ToString(),
                    AuthorName = newReview.AuthorName,
                    ReviewText = newReview.ReviewText,
                    Score = newReview.Score,
                    SubjectId = newReview.SubjectId,
                    Subject = new Game
                    {
                        Id = newReview.SubjectId,
                        Name = "Lorem Ipsum",
                        ReleasedOn = DateTime.Now
                    }
                });
            });

            var result = _controller.Create(newReview);

            result.Should()
            .NotBeNull("a result is always expected").And
            .BeAssignableTo <IActionResult>("should implement IActionResult").And
            .BeOfType <CreatedResult>("it should be a Created result").Which
            .Value.Should()
            .NotBeNull("a object is always excepcted").And
            .BeOfType <ReviewView>("it should be the review we just sent");

            var createdReview = (result as CreatedResult).Value as ReviewView;

            createdReview.Should()
            .BeEquivalentTo(newReview, cfg => cfg.ExcludingMissingMembers(), because: "it should be equal to the one we sent to the controller");
        }
Exemplo n.º 11
0
        public async Task CanCreateReviewOnStep()
        {
            // Arrange - create the mock repository with a step
            TestTrekStoriesContext tc = new TestTrekStoriesContext();
            Step step1 = new Step {
                StepId = 1, From = "A", To = "B"
            };

            tc.Steps.Add(step1);
            // Arrange - create the controller
            ReviewController controller = new ReviewController(tc);
            // Act
            var result = await controller.Create(1) as ViewResult;

            var review = (Review)result.ViewData.Model;

            // Assert
            Assert.AreEqual("Edit", result.ViewName);
            Assert.AreEqual(1, review.StepId);
        }
Exemplo n.º 12
0
        public void create_action_should_render_default_view()
        {
            var result = _reviewController.Create() as ViewResult;

            Assert.AreEqual(result.ViewName, "");
        }