public void IfFileDoesNotExistsSetsStatusTo404() { DefaultStaticResourceRegistry registry = new DefaultStaticResourceRegistry(); ResourceFileHandler handler = new ResourceFileHandler( new UrlInfo( "", "controller", "action" ), registry ); StringWriter writer = new StringWriter(); HttpResponse response = new HttpResponse( writer ); HttpRequest request = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt" ), "http://localhost:1333/controller/action", "" ); handler.ProcessRequest( new HttpContext( request, response ) ); Assert.AreEqual( 404, response.StatusCode ); }
public void ReturnsResourceContentAndSetMimeType() { ICacheProvider cacheProvider = new MockCacheProvider(); DefaultStaticResourceRegistry registry = new DefaultStaticResourceRegistry( cacheProvider ); registry.RegisterCustomResource( "key", null, null, new StaticContentResource( "js" ), "text/javascript" ); ResourceFileHandler handler = new ResourceFileHandler( new UrlInfo( "", "controller", "key" ), registry ); StringWriter writer = new StringWriter(); HttpResponse response = new HttpResponse( writer ); HttpRequest request = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt" ), "http://localhost:1333/controller/action", "" ); handler.ProcessRequest( new HttpContext( request, response ) ); Assert.AreEqual( 200, response.StatusCode ); Assert.AreEqual( "text/javascript", response.ContentType ); Assert.AreEqual( "js", writer.GetStringBuilder().ToString() ); }