當前位置: 首頁>>代碼示例>>C#>>正文


C# ProductController.GetImage方法代碼示例

本文整理匯總了C#中SportsStore.WebUI.Controllers.ProductController.GetImage方法的典型用法代碼示例。如果您正苦於以下問題:C# ProductController.GetImage方法的具體用法?C# ProductController.GetImage怎麽用?C# ProductController.GetImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SportsStore.WebUI.Controllers.ProductController的用法示例。


在下文中一共展示了ProductController.GetImage方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Cannot_Retrieve_Image_Data_For_Invalid_Id

        public void Cannot_Retrieve_Image_Data_For_Invalid_Id()
        {
            // Arrange
            Product prod = new Product
            {
                ProductId = 2,
                Name = "Test",
                ImageData = new byte[] { },
                ImageMimeType = "image/png"
            };

            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product { ProductId = 1, Name = "P1" },
                new Product { ProductId = 2, Name = "P2" }
            }.AsQueryable());

            ProductController target = new ProductController(mock.Object);

            // Act
            ActionResult result = target.GetImage(100);

            // Assert
            Assert.IsNull(result);
        }
開發者ID:nhebb,項目名稱:ProMVC5,代碼行數:25,代碼來源:ImageTests.cs

示例2: Can_Retrieve_Image_Data

        public void Can_Retrieve_Image_Data()
        {
            // Arrange - create a Product with image data
            Product prod = new Product
            {
                ProductID = 2,
                Name = "Test",
                ImageData = new byte[] { },
                ImageMimeType = "image/png"
            };

            // Arrange - create the mock repository
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product {ProductID = 1, Name = "P1"},
                prod,
                new Product {ProductID = 3, Name = "P3"}
            }.AsQueryable());

            // Arrange - create the controller
            ProductController target = new ProductController(mock.Object);

            // Act - call the GetImage action method
            ActionResult result = target.GetImage(2);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual(prod.ImageMimeType, ((FileResult)result).ContentType);
        }
開發者ID:afrancocode,項目名稱:Test,代碼行數:30,代碼來源:ImageTests.cs

示例3: Can_Retrieve_Image_Data

        public void Can_Retrieve_Image_Data()
        {
            Product product = new Product
            {
                ProductID = 2,
                Name = "Test",
                ImageData = new byte[] {},
                ImageMimeType = "image/png"
            };

            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product {ProductID = 1, Name = "P1"},
                product,
                new Product {ProductID = 1, Name = "P3"}
            }.AsQueryable());

            ProductController target = new ProductController(mock.Object);

            ActionResult result = target.GetImage(2);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual(product.ImageMimeType,((FileResult)result).ContentType);
        }
開發者ID:SHassona,項目名稱:Personal-Repository,代碼行數:26,代碼來源:ImageTests.cs

示例4: Cant_Retrieve_NonExistint_Image_Data

        public void Cant_Retrieve_NonExistint_Image_Data()
        {
            // Arrange - create a Product with image data
            Product prod = new Product
            {
                ProductID = 2,
                Name = "Test",
                ImageData = new byte[] { },
                ImageMimeType = "image/png"
            };

            // Arrange - create the mock repository
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product {ProductID = 1, Name = "P1"},
                prod,
                new Product {ProductID = 3, Name = "P3"}
            }.AsQueryable());

            // Arrange - create the controller
            ProductController target = new ProductController(mock.Object);

            // Act - call the GetImage action method
            ActionResult result = target.GetImage(3);

            // Assert
            Assert.IsNull(result);
        }
開發者ID:najamsk,項目名稱:SportsStore,代碼行數:28,代碼來源:ProductControllerTest.cs

示例5: ProductController_GetImage_CanRetrieveImageData

        public void ProductController_GetImage_CanRetrieveImageData()
        {
            // Arrange
            var prod = new Product
            {
                ProductID = 2,
                Name = "Test",
                ImageData = new byte[] { },
                ImageMimeType = "image/png"
            };
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product {ProductID = 1, Name = "P1", Category = "Cat1" },
                prod,
                new Product {ProductID = 3, Name = "P3", Category = "Cat1" },

            }.AsQueryable());
            var target = new ProductController(mock.Object);

            // Act
            var result = target.GetImage(2);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual(prod.ImageMimeType, ((FileResult)result).ContentType);
        }
開發者ID:nitzerebbnitzerebb,項目名稱:Lab2,代碼行數:27,代碼來源:ProductControllerTests.cs

示例6: Can_Retreive_Image_Data

        public void Can_Retreive_Image_Data()
        {
            //Arrange - create a product with image data
            Product prod = new Product
            {
                ProductID = 2,
                Name = "test",
                ImageData = new Byte[] { },
                ImageMimeType = "image/png"

            };

            //Arrange -create a mock repository

            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(p => p.Products).Returns(new Product[] { 
                new Product{ProductID=1,Name="P1"},
                prod,
                new Product{ProductID=3,Name="P3"}           
            
            }.AsQueryable());

            ProductController controller = new ProductController(mock.Object);

            ActionResult result = controller.GetImage(2);

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual(prod.ImageMimeType, ((FileResult)result).ContentType);

        }
開發者ID:KannugoPrithvi,項目名稱:SportStore,代碼行數:32,代碼來源:ImageTests.cs

示例7: Cannot_Retrieve_Image_Data_For_Invalid_ID

        public void Cannot_Retrieve_Image_Data_For_Invalid_ID()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product { ProductID = 1, Name = "P1"},
                new Product { ProductID=2, Name = "P2"}
            }.AsQueryable());
            ProductController target = new ProductController(mock.Object);

            ActionResult result = target.GetImage(100);

            Assert.IsNull(result);
        }
開發者ID:n4ppy,項目名稱:SportsStore,代碼行數:13,代碼來源:ImageTests.cs

示例8: Cannot_Retrieve_Image_Data_For_Invalid_ID

 public void Cannot_Retrieve_Image_Data_For_Invalid_ID()
 {
     // Arrange - create the mock repository
     Mock<IProductRepository> mock = new Mock<IProductRepository>();
     mock.Setup(m => m.Products).Returns(new Product[] {
         new Product {ProductID = 1, Name = "P1"},
         new Product {ProductID = 2, Name = "P2"}
     }.AsQueryable());
     // Arrange - create the controller
     ProductController target = new ProductController(mock.Object);
     // Act - call the GetImage action method
     ActionResult result = target.GetImage(100);
     // Assert
     Assert.IsNull(result);
 }
開發者ID:tofka,項目名稱:Lab-3,代碼行數:15,代碼來源:ProductControllerTest.cs

示例9: ProductController_GetImage_CannotRetrieveImageDataForInvalidID

        public void ProductController_GetImage_CannotRetrieveImageDataForInvalidID()
        {
            // Arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product {ProductID = 1, Name = "P1", Category = "Cat1" },
                new Product {ProductID = 3, Name = "P3", Category = "Cat1" },

            }.AsQueryable());
            var target = new ProductController(mock.Object);

            // Act
            var result = target.GetImage(100);

            // Assert
            Assert.IsNull(result);
        }
開發者ID:nitzerebbnitzerebb,項目名稱:Lab2,代碼行數:17,代碼來源:ProductControllerTests.cs

示例10: Cannot_Retrieve_Image_Data_For_Invalid_ID

        public void Cannot_Retrieve_Image_Data_For_Invalid_ID()
        {
            // arrange, create mock repo
            Mock<IProductRepository> mock = new Mock<IProductRepository>();

            // create products
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product() {ProductID = 1, Name = "P1"},
                new Product() {ProductID = 2, Name = "P2"}
            }.AsQueryable);

            // create controller
            ProductController controller = new ProductController(mock.Object);

            var result = controller.GetImage(3);

            Assert.IsNull(result);
        }
開發者ID:mtetik,項目名稱:MvcTestApp,代碼行數:19,代碼來源:ImageTests.cs

示例11: Can_Retrieve_Image_Data

        public void Can_Retrieve_Image_Data() 
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            
            Product prod = new Product() {ProductID = 3, Name = "P3", ImageData = new byte[]{}, ImageMimeType = "image/png"};
            
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product() {ProductID = 1, Name = "P1"},
                prod,
                new Product() {ProductID = 2, Name = "P2"}
            }.AsQueryable());

            // create controller
            ProductController controller = new ProductController(mock.Object);

            var result = controller.GetImage(3);

            // assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(FileResult));
            Assert.AreEqual("image/png", ((FileResult)result).ContentType);

        }
開發者ID:mtetik,項目名稱:MvcTestApp,代碼行數:24,代碼來源:ImageTests.cs


注:本文中的SportsStore.WebUI.Controllers.ProductController.GetImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。