本文整理汇总了C#中RequestReduce.Module.RequestReduceModule.HandleRRContent方法的典型用法代码示例。如果您正苦于以下问题:C# RequestReduceModule.HandleRRContent方法的具体用法?C# RequestReduceModule.HandleRRContent怎么用?C# RequestReduceModule.HandleRRContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestReduce.Module.RequestReduceModule
的用法示例。
在下文中一共展示了RequestReduceModule.HandleRRContent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WillCorrectlySetContentType
public void WillCorrectlySetContentType(string path, string contentType, bool contentInStore)
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var response = new Mock<HttpResponseBase>();
response.SetupProperty(x => x.ContentType);
response.Setup(x => x.Headers).Returns(new NameValueCollection());
response.Setup(x => x.Cache).Returns(new Mock<HttpCachePolicyBase>().Object);
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Response).Returns(response.Object);
context.Setup(x => x.Request.RawUrl).Returns(path);
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var store = new Mock<IStore>();
store.Setup(
x => x.SendContent(It.IsAny<string>(), response.Object)).
Returns(contentInStore);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use(new UriBuilder(config.Object));
});
module.HandleRRContent(context.Object);
Assert.Equal(contentType, response.Object.ContentType);
RRContainer.Current = null;
}
示例2: WillDelegateContentMappedToHandler
public void WillDelegateContentMappedToHandler()
{
var module = new RequestReduceModule();
var handler = new DefaultHttpHandler();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.Url).Returns(new Uri("http://host/content/someresource.less"));
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Items).Returns(new Hashtable());
var handlerFactory = new HandlerFactory(config.Object, new UriBuilder(config.Object));
handlerFactory.AddHandlerMap(x => x.AbsolutePath.EndsWith(".less") ? handler : null);
handlerFactory.AddHandlerMap(x => x.AbsolutePath.EndsWith(".les") ? new DefaultHttpHandler() : null);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IUriBuilder>().Use<UriBuilder>();
x.For<IHandlerFactory>().Use(handlerFactory);
});
module.HandleRRContent(context.Object);
Assert.Equal(handler, context.Object.Items["remapped handler"]);
RRContainer.Current = null;
}
示例3: WillSetPhysicalPathToMappedVirtualPathWhenHandlingContent
public void WillSetPhysicalPathToMappedVirtualPathWhenHandlingContent()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/Virtual");
context.Setup(x => x.Server.MapPath("/Virtual")).Returns("physical");
context.Setup(x => x.Request.RawUrl).Returns("/Virtual/blah");
context.Setup(x => x.Response.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
var cache = new Mock<HttpCachePolicyBase>();
context.Setup(x => x.Response.Cache).Returns(cache.Object);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(new Mock<IStore>().Object);
x.For<IUriBuilder>().Use(new Mock<IUriBuilder>().Object);
});
module.HandleRRContent(context.Object);
config.VerifySet(x => x.SpritePhysicalPath = "physical", Times.Once());
RRContainer.Current = null;
}
示例4: WillSetCachabilityIfInRRPathAndStoreSendsContent
public void WillSetCachabilityIfInRRPathAndStoreSendsContent(string path)
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/css.css");
context.Setup(x => x.Request.Url).Returns(new Uri("http://localhost/RRContent/css.css"));
context.Setup(x => x.Response.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
var cache = new Mock<HttpCachePolicyBase>();
context.Setup(x => x.Response.Cache).Returns(cache.Object);
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns(path);
var store = new Mock<IStore>();
store.Setup(
x => x.SendContent(It.IsAny<string>(), context.Object.Response)).
Returns(true);
var builder = new Mock<IUriBuilder>();
builder.Setup(x => x.ParseSignature("/RRContent/css.css")).Returns("sig");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use(builder.Object);
});
module.HandleRRContent(context.Object);
Assert.Equal(60*24*360, context.Object.Response.Expires);
cache.Verify(x => x.SetETag(@"""sig"""), Times.Once());
cache.Verify(x => x.SetCacheability(HttpCacheability.Public), Times.Once());
RRContainer.Current = null;
}
示例5: WillNotSetCachabilityIfNotInRRPatOrStoreDoesNotSendContent
public void WillNotSetCachabilityIfNotInRRPatOrStoreDoesNotSendContent(string path, bool contentSent)
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/css.css");
context.Setup(x => x.Request.Url).Returns(new Uri("http://localhost/RRContent/css.css"));
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
var cache = new Mock<HttpCachePolicyBase>();
context.Setup(x => x.Response.Cache).Returns(cache.Object);
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns(path);
var store = new Mock<IStore>();
store.Setup(
x => x.SendContent(It.IsAny<string>(), context.Object.Response)).
Returns(contentSent);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use(new UriBuilder(config.Object));
});
module.HandleRRContent(context.Object);
cache.Verify(x => x.SetCacheability(HttpCacheability.Public), Times.Never());
RRContainer.Current = null;
}
示例6: WillNotHandleRequestsNotInMyDirectory
public void WillNotHandleRequestsNotInMyDirectory()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContents/someresource");
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
var store = new Mock<IStore>();
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use<UriBuilder>();
});
module.HandleRRContent(context.Object);
store.Verify(x => x.SendContent(It.IsAny<string>(), It.IsAny<HttpResponseBase>()), Times.Never());
RRContainer.Current = null;
}
示例7: WillHonorEtagsandReturn304WhenTheyMatchIfNoneMatch
public void WillHonorEtagsandReturn304WhenTheyMatchIfNoneMatch()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/key-match-css.css");
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection() { { "If-None-Match", @"""match""" } });
context.Setup(x => x.Request.Url).Returns(new Uri("http://localhost/RRContent/key-match-css.css"));
context.Setup(x => x.Response.Headers).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
var cache = new Mock<HttpCachePolicyBase>();
context.Setup(x => x.Response.Cache).Returns(cache.Object);
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var store = new Mock<IStore>();
var builder = new Mock<IUriBuilder>();
builder.Setup(x => x.ParseSignature("/RRContent/key-match-css.css")).Returns("match");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use(builder.Object);
});
module.HandleRRContent(context.Object);
Assert.Equal(60 * 24 * 360, context.Object.Response.Expires);
cache.Verify(x => x.SetETag(@"""match"""), Times.Once());
cache.Verify(x => x.SetCacheability(HttpCacheability.Public), Times.Once());
Assert.Equal(304, context.Object.Response.StatusCode);
store.Verify(x => x.SendContent(It.IsAny<string>(), context.Object.Response), Times.Never());
RRContainer.Current = null;
}
示例8: WillStripQueryStringDromGeneratedUrls
public void WillStripQueryStringDromGeneratedUrls()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/key-match-css.css?somequerystring");
context.Setup(x => x.Request.Url).Returns(new Uri("http://localhost/RRContent/key-match-css.css?somequerystring"));
context.Setup(x => x.Request.Headers).Returns(new NameValueCollection() { { "If-None-Match", @"""match""" } });
context.Setup(x => x.Response.Headers).Returns(new NameValueCollection());
var cache = new Mock<HttpCachePolicyBase>();
context.Setup(x => x.Response.Cache).Returns(cache.Object);
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var store = new Mock<IStore>();
var builder = new Mock<IUriBuilder>();
builder.Setup(x => x.ParseSignature("/RRContent/key-match-css.css")).Returns("match");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IHostingEnvironmentWrapper>().Use(new Mock<IHostingEnvironmentWrapper>().Object);
x.For<IStore>().Use(store.Object);
x.For<IUriBuilder>().Use(builder.Object);
});
module.HandleRRContent(context.Object);
store.Verify(x => x.SendContent("/RRContent/key-match-css.css", context.Object.Response), Times.Never());
RRContainer.Current = null;
}