public void Detail_HttpGet_ReturnsDetailViewForValidId()
        {
            //Arrange
            //Mock our DAL to return a Product for any Id
            Product fakeProduct = new Product()
            {
                ProductId = 1,
                Name      = "Fake Product"
            };
            Mock <IProductDAL> mockDal = new Mock <IProductDAL>();

            mockDal.Setup(m => m.GetProduct(1)).Returns(fakeProduct);
            // The above line reads
            // "When GetProduct is called on the IProductDAL, with the integer 1, return a
            // fake product with id 1."
            StoreController controller = new StoreController(mockDal.Object);

            //Act
            ViewResult result = controller.Detail(1) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Detail", result.ViewName);
            Assert.AreEqual(fakeProduct, result.Model);
        }
        public void InvalidProductId_Returns_HttpNotFound()
        {
            Mock <IProductDAL> mockDal = new Mock <IProductDAL>();

            mockDal.Setup(m => m.GetProduct(It.IsAny <int>())).Returns <Product>(null);

            StoreController controller = new StoreController(mockDal.Object);

            var result = controller.Detail(1) as HttpNotFoundResult;

            Assert.IsNotNull(result);
        }
        public void AddToCart_HttpPost_Returns404ForInvalidId()
        {
            //Arrange
            Mock <IProductDAL> productDal = new Mock <IProductDAL>();

            productDal.Setup(m => m.GetProduct(It.IsAny <int>())).Returns <Product>(null);

            StoreController controller = new StoreController(productDal.Object);

            //Act
            HttpNotFoundResult result = controller.Detail(1) as HttpNotFoundResult;

            //Assert
            Assert.IsNotNull(result);
        }
        public void Detail_HttpGet_Returns404ForInvalidId()
        {
            //Arrange
            Mock <IProductDAL> mockDal = new Mock <IProductDAL>();

            mockDal.Setup(m => m.GetProduct(It.IsAny <int>())).Returns <Product>(null);
            // The above line reads
            // "When GetProduct is called on the IProductDAL, for any integer, return null."
            StoreController controller = new StoreController(mockDal.Object);

            //Act
            HttpNotFoundResult result = controller.Detail(1) as HttpNotFoundResult;

            //Assert
            Assert.IsNotNull(result);
        }
        public void ValidProductId_Returns_DetailView()
        {
            Mock <IProductDAL> mockDal = new Mock <IProductDAL>();

            mockDal.Setup(m => m.GetProduct(1)).Returns(new SSGeek.Models.Product()
            {
                ProductId = 1,
                Name      = "Fake Product"
            });
            StoreController controller = new StoreController(mockDal.Object);


            var result = controller.Detail(1) as ViewResult;


            Assert.IsNotNull(result);
            Assert.AreEqual("Detail", result.ViewName);
            Assert.IsNotNull(result.Model);
        }