public void ResourceHandlerThrows404IfResourceNotFound() {
            // Arrange
            var applicationPart = new ApplicationPart(BuildAssembly(), "~/my-app-assembly");
            MemoryStream stream = new MemoryStream();
            var response = new Mock<HttpResponseBase>();
            response.SetupGet(c => c.OutputStream).Returns(stream);
            response.SetupSet(c => c.ContentType = "image/jpeg").Verifiable();
            var resourceHandler = new ResourceHandler(applicationPart, "does-not-exist");

            // Act and Assert
            ExceptionAssert.Throws<HttpException>(() => resourceHandler.ProcessRequest(response.Object),
                "The resource file \"does-not-exist\" could not be found.");
        }
        public void ResourceHandlerWritesContentsOfFileToStream() {
            // Arrange
            var applicationPart = new ApplicationPart(BuildAssembly(), "~/my-app-assembly");
            MemoryStream stream = new MemoryStream();
            var response = new Mock<HttpResponseBase>();
            response.SetupGet(c => c.OutputStream).Returns(stream);
            response.SetupSet(c => c.ContentType = "image/jpeg").Verifiable();
            var resourceHandler = new ResourceHandler(applicationPart, "bar.foo.jpg");

            // Act
            resourceHandler.ProcessRequest(response.Object);

            // Assert
            response.Verify();
            Assert.AreEqual(Encoding.Default.GetString(stream.ToArray()), _fileContent);
        }