public void Can_add_a_product_via_a_controller()
        {
            IHypermartContext x = new FakeHypermartContext();

            var controller = new ProductsController { db = x };

            var fakeHTTPSession = new  FonySession();
            fakeHTTPSession.AddFileUpload(new PhonyUploadFile("Screensjot.jpg", GetResourceAsStrream("TestAPI.img100.jpg"), "JPG"));
            controller.ControllerContext = fakeHTTPSession.BuildControllerContext(controller);
            controller.Url = new UrlHelper(fakeHTTPSession.BuildRequestContext());

            var res = controller.Create(new Product
            {
                ID = 1,
                Description = "NewProd",
                Files = null,
                Lead = "Lead USer",
                Maintainers = new List<String> { "m1", "m2", "m3" },
                Screenshots = new List<Screenshot>(),
                SourceCode = null,
                Tagline = "TagLine",
                Title = "Title"
            });

            Assert.AreEqual(1, controller.db.Products.Count());
        }
        public void testIndesReturnsAViewForTheRelevantProductID()
        {
            var Products = new List<Product>
            {
                new Product{ID = 1,Title = "FirstProduct",Description = "First Product In Database"}
            }.AsQueryable();

            Mock<IHypermartContext> mockDBContext = new Mock<IHypermartContext>();

            var mockSet = new Mock<DbSet<Product>>();
            mockSet.As<IQueryable<Product>>().Setup(m => m.Provider).Returns(Products.Provider);
            mockSet.As<IQueryable<Product>>().Setup(m => m.Expression).Returns(Products.Expression);
            mockSet.As<IQueryable<Product>>().Setup(m => m.ElementType).Returns(Products.ElementType);
            mockSet.As<IQueryable<Product>>().Setup(m => m.GetEnumerator()).Returns(Products.GetEnumerator());

            mockDBContext.Setup(x => x.Products).Returns(mockSet.Object);

            var xy = mockDBContext.Object.Products.ToList();

            ProductsController SUT = new ProductsController(mockDBContext.Object);
            ActionResult  ViewResults =SUT.Index();
            ViewResult vResult = ViewResults as ViewResult;
            if (vResult != null)
            {
                Assert.AreEqual(string.Empty, vResult.ViewName);
                //Assert.IsInstanceOfType(typeof(Product),vResult.Model.GetType() );
                //Product model = vResult.Model as Product;
                //if (model != null)
                //{
                //    //...
                //}
            }
        }