public void AddProductPost_CorrectProduct_ReturnsCorrectRedirectToRouteResult()
        {
            // Arrange
            Mock <IProductProvider> productProviderMock = new Mock <IProductProvider>();
            Mock <IProductHandler>  productHandlerMock  = new Mock <IProductHandler>();

            productHandlerMock.Setup(x => x.Add(It.IsAny <Product>()))
            .Returns(1);
            Mock <IProductValidator> productValidatorMock = new Mock <IProductValidator>();

            productValidatorMock.Setup(x => x.CanAddProduct(It.IsAny <Product>()))
            .Returns(new List <KeyValuePair <string, string> >());

            ProductController controller = new ProductController(productProviderMock.Object, productHandlerMock.Object, productValidatorMock.Object);
            // Act
            RedirectToRouteResult result = controller.AddProductPost(this.products[0]) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("GetProductList", result.RouteValues.FirstOrDefault().Value);
        }
        public void AddProductPost_NullProdut_ReturnsCorrectViewResult()
        {
            // Arrange
            Mock <IProductProvider>  productProviderMock  = new Mock <IProductProvider>();
            Mock <IProductHandler>   productHandlerMock   = new Mock <IProductHandler>();
            Mock <IProductValidator> productValidatorMock = new Mock <IProductValidator>();

            productValidatorMock.Setup(x => x.CanAddProduct(null))
            .Throws <ArgumentNullException>();

            ProductController controller = new ProductController(productProviderMock.Object, productHandlerMock.Object, productValidatorMock.Object);
            // Act
            ViewResult result = controller.AddProductPost(null) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsFalse(controller.ModelState.IsValid);
            Assert.AreEqual(1, controller.ModelState.Keys.Count);
            Assert.AreEqual("", controller.ModelState.Keys.FirstOrDefault());
            Assert.AreEqual("AddProduct", result.ViewName);
        }