Exemplo n.º 1
0
        public void Cannot_Retrieve_Sample_Thumbnail_Data_For_Invalid_ID()
        {
            // Arrange - create a Sample with image (thumbnail) data
            Sample sample = new Sample
            {
                Id = 1,
                Thumbnail = new byte[] { }
            };

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

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

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

            // Assert
            Assert.IsInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest);
        }
Exemplo n.º 2
0
        public void Can_Retrieve_Sample_Thumbnail_Data()
        {
            // Arrange - create a Sample with image (thumbnail) data
            Sample sample = new Sample
            {
                Id = 1,
                Thumbnail = new byte[] { }
            };

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

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

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

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