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()); }
public void IfFileDoesNotExistsSetsStatusTo404() { var registry = new DefaultStaticResourceRegistry(); var handler = new ResourceFileHandler(new UrlInfo("", "controller", "action"), registry); var writer = new StringWriter(); var res = new HttpResponse(writer); var req = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt"), "http://localhost:1333/controller/action", ""); handler.ProcessRequest(new HttpContext(req, res)); Assert.AreEqual(404, res.StatusCode); }
public void IfFileDoesNotExistsSetsStatusTo404() { var registry = new DefaultStaticResourceRegistry(); var handler = new ResourceFileHandler(new UrlInfo("", "controller", "action"), registry); var writer = new StringWriter(); var res = new HttpResponse(writer); var req = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt"), "http://localhost:1333/controller/action", ""); handler.ProcessRequest(new HttpContext(req, res)); Assert.AreEqual(404, res.StatusCode); }
public void ReturnsResourceContentAndSetMimeType() { var registry = new DefaultStaticResourceRegistry(); registry.RegisterCustomResource("key", null, null, new StaticContentResource("js"), "text/javascript", null); var handler = new ResourceFileHandler(new UrlInfo("", "controller", "key"), registry); var writer = new StringWriter(); var res = new HttpResponse(writer); var req = new HttpRequest( Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "Handlers/Files/simplerequest.txt"), "http://localhost:1333/controller/action", ""); handler.ProcessRequest(new HttpContext(req, res)); Assert.AreEqual(200, res.StatusCode); Assert.AreEqual("text/javascript", res.ContentType); Assert.AreEqual("js", writer.GetStringBuilder().ToString()); }