public void ViewCreateForm_AlwaysReturnsView()
        {
            // Arrange
            var fruitRepositoryMock = new Mock <IFruitRepository>();
            var controller          = new FruitsController(fruitRepositoryMock.Object);

            // Act
            var result = controller.Create();

            // Assert
            Assert.IsType <ViewResult>(result);
        }
        public void SubmitCreate_IncorrectInput_ReturnsViewAgain()
        {
            // Arrange
            var fruitRepositoryMock = new Mock <IFruitRepository>();
            var controller          = new FruitsController(fruitRepositoryMock.Object);
            var itemToInsert        = new Fruit {
                Id = 1
            };                                       // Missing name!

            // Act
            var result = controller.Create(itemToInsert).Result;

            // Assert
            Assert.IsType <ViewResult>(result);
        }
        public void SubmitCreate_CorrectInput_RedirectsOnSuccess()
        {
            // Arrange
            var fruitRepositoryMock = new Mock <IFruitRepository>();
            var controller          = new FruitsController(fruitRepositoryMock.Object);
            var itemToInsert        = new Fruit
            {
                Id          = 1,
                Color       = Color.Red,
                Name        = "Apple",
                Price       = 2.99m,
                Rating      = 5,
                Description = "An apple",
                Image       = "apple.jpeg"
            };

            // Act

            var result = controller.Create(itemToInsert).Result;

            // Assert
            Assert.IsType <RedirectToActionResult>(result);
        }