本文整理汇总了C#中RequestReduce.Module.RequestReduceModule.InstallFilter方法的典型用法代码示例。如果您正苦于以下问题:C# RequestReduceModule.InstallFilter方法的具体用法?C# RequestReduceModule.InstallFilter怎么用?C# RequestReduceModule.InstallFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestReduce.Module.RequestReduceModule
的用法示例。
在下文中一共展示了RequestReduceModule.InstallFilter方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WillGetAndSetResponseFilterIfXHtmlContent
public void WillGetAndSetResponseFilterIfXHtmlContent()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.ResourceAbsolutePath).Returns("/Virtual");
context.Setup(x => x.Items.Contains(ResponseFilter.ContextKey)).Returns(false);
context.Setup(x => x.Request.Url).Returns(new Uri("http://host/Content/blah"));
context.Setup(x => x.Response.ContentType).Returns("application/xhtml+xml");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IHostingEnvironmentWrapper>().Use(new Mock<IHostingEnvironmentWrapper>().Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifyGet(x => x.Response.Filter, Times.Once());
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Once());
RRContainer.Current = null;
}
示例2: WillSetResponseFilterOnce
public void WillSetResponseFilterOnce()
{
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.Items.Contains(RequestReduceModule.ContextKey)).Returns(true);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifySet((x => x.Response.Filter = It.IsAny<Stream>()), Times.Never());
RRContainer.Current = null;
}
示例3: WillSetResponseFilterIfJustJsProcessingIsDisabledFromConfig
public void WillSetResponseFilterIfJustJsProcessingIsDisabledFromConfig()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/Virtual");
config.Setup(x => x.JavaScriptProcessingDisabled).Returns(true);
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.ContextKey)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Request.RawUrl).Returns("/NotVirtual/blah");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Once());
RRContainer.Current = null;
}
示例4: WillSetPhysicalPathToMappedVirtualPath
public void WillSetPhysicalPathToMappedVirtualPath()
{
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.Items.Contains(RequestReduceModule.ContextKey)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Server.MapPath("/Virtual")).Returns("physical");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
config.VerifySet(x => x.SpritePhysicalPath = "physical", Times.Once());
RRContainer.Current = null;
}
示例5: WillSetContextKeyIfNotSetBefore
public void WillSetContextKeyIfNotSetBefore()
{
RRContainer.Current = null;
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.Items.Contains(RequestReduceModule.ContextKey)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("type");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.Verify(x => x.Items.Add(RequestReduceModule.ContextKey, It.IsAny<Object>()), Times.Once());
RRContainer.Current = null;
}
示例6: WillNotSetResponseFilterIfStatusIs302Or301
public void WillNotSetResponseFilterIfStatusIs302Or301(int status)
{
RRContainer.Current = null;
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.Items.Contains(RequestReduceModule.ContextKey)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
context.Setup(x => x.Response.StatusCode).Returns(status);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Never());
RRContainer.Current = null;
}
示例7: WillNotSetResponseFilterIfRRFilterQSIsDisabled
public void WillNotSetResponseFilterIfRRFilterQSIsDisabled()
{
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.Request.RawUrl).Returns("/NotVirtual/blah");
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection() {{"RRFilter", "disabled"}});
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Never());
RRContainer.Current = null;
}
示例8: WillNotSetPhysicalPathToMappedPathOfVirtualPathIfPhysicalPathIsNotEmpty
public void WillNotSetPhysicalPathToMappedPathOfVirtualPathIfPhysicalPathIsNotEmpty()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpritePhysicalPath).Returns("physicalPath");
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
module.InstallFilter(context.Object);
config.VerifySet(x => x.SpritePhysicalPath = It.IsAny<string>(), Times.Never());
RRContainer.Current = null;
}
示例9: WillNotSetResponseFilterIfFaviconIco
public void WillNotSetResponseFilterIfFaviconIco()
{
RRContainer.Current = null;
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.ResourceVirtualPath).Returns("/Virtual");
context.Setup(x => x.Items.Contains(ResponseFilter.ContextKey)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Request.Url).Returns(new Uri("http://host/favicon.ico"));
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<AbstractFilter>().Use(new Mock<AbstractFilter>().Object);
});
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Never());
RRContainer.Current = null;
}
示例10: WillSetResponseFilterOnce
public void WillSetResponseFilterOnce()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(true);
module.InstallFilter(context.Object);
context.VerifySet((x => x.Response.Filter = It.IsAny<Stream>()), Times.Never());
}
示例11: WillSetResponseFilterIfHtmlContent
public void WillSetResponseFilterIfHtmlContent()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Once());
}
示例12: WillSetContextKeyIfNotSetBefore
public void WillSetContextKeyIfNotSetBefore()
{
RRContainer.Current = null;
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("type");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.RawUrl).Returns("/content/blah");
module.InstallFilter(context.Object);
context.Verify(x => x.Items.Add(RequestReduceModule.CONTEXT_KEY, It.IsAny<Object>()), Times.Once());
}
示例13: WillNotSetResponseFilterIfRRFilterQSIsDisabled
public void WillNotSetResponseFilterIfRRFilterQSIsDisabled()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection() {{"RRFilter", "disabled"}});
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Never());
}
示例14: WillNotSetResponseFilterIfRRFilterIsDisabledFromConfig
public void WillNotSetResponseFilterIfRRFilterIsDisabledFromConfig()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.CssProcesingDisabled).Returns(true);
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Items.Contains(RequestReduceModule.CONTEXT_KEY)).Returns(false);
context.Setup(x => x.Response.ContentType).Returns("text/html");
context.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
RRContainer.Current = new Container(x => x.For<IRRConfiguration>().Use(config.Object));
module.InstallFilter(context.Object);
context.VerifySet(x => x.Response.Filter = It.IsAny<Stream>(), Times.Never());
RRContainer.Current = null;
}