Exemplo n.º 1
0
        public void Cannot_Retrieve_ClipartImage_Data_For_Invalid_ID()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id    = 1,
                Name  = "ClipartTemplate2",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock <IRepository <ClipartTemplate> > mock = new Mock <IRepository <ClipartTemplate> >();

            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

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

            // Act - call the Image method
            HttpResponseMessage result = target.Image(100);

            // Assert
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest);
        }
Exemplo n.º 2
0
        public void Can_Retrieve_Clipart_Image_Data()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id    = 1,
                Name  = "ClipartTemplate1",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock <IRepository <ClipartTemplate> > mock = new Mock <IRepository <ClipartTemplate> >();

            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

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

            // Act - call the Image method
            HttpResponseMessage result = target.Image(1);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Content.Headers.ContentType.MediaType, "image/png");
        }
Exemplo n.º 3
0
        public void Cannot_Retrieve_ClipartImage_Data_For_Invalid_ID()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id = 1,
                Name = "ClipartTemplate2",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock<IRepository<ClipartTemplate>> mock = new Mock<IRepository<ClipartTemplate>>();
            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

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

            // Act - call the Image method
            HttpResponseMessage result = target.Image(100);

            // Assert
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest);
        }
Exemplo n.º 4
0
        public void Can_Retrieve_Clipart_Image_Data()
        {
            // Arrange - create a ClipartTemplate with image data
            ClipartTemplate clipartTemplate = new ClipartTemplate
            {
                Id = 1,
                Name = "ClipartTemplate1",
                Image = new byte[] { }
            };

            // Arrange - create the mock repository
            Mock<IRepository<ClipartTemplate>> mock = new Mock<IRepository<ClipartTemplate>>();
            mock.Setup(m => m.Get(1)).Returns(clipartTemplate);

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

            // Act - call the Image method
            HttpResponseMessage result = target.Image(1);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.Content.Headers.ContentType.MediaType, "image/png");
        }