本文整理汇总了C#中RequestReduce.Module.RequestReduceModule.HandleRRFlush方法的典型用法代码示例。如果您正苦于以下问题:C# RequestReduceModule.HandleRRFlush方法的具体用法?C# RequestReduceModule.HandleRRFlush怎么用?C# RequestReduceModule.HandleRRFlush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestReduce.Module.RequestReduceModule
的用法示例。
在下文中一共展示了RequestReduceModule.HandleRRFlush方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WillFlushFailuresOnFlushFailureUrlWhenAndAuthorizedUsersIsAnonymous
public void WillFlushFailuresOnFlushFailureUrlWhenAndAuthorizedUsersIsAnonymous()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/FlushFailures");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(false);
context.Setup(x => x.User.Identity).Returns(identity.Object);
var queue = new Mock<IReducingQueue>();
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IReducingQueue>().Use(queue.Object);
x.For<IUriBuilder>().Use<UriBuilder>();
});
module.HandleRRFlush(context.Object);
queue.Verify(x => x.ClearFailures(), Times.Once());
RRContainer.Current = null;
}
示例2: WillSetPhysicalPathToMappedVirtualPathOnFlush
public void WillSetPhysicalPathToMappedVirtualPathOnFlush()
{
var module = new RequestReduceModule();
var context = new Mock<HttpContextBase>();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
context.Setup(x => x.Server.MapPath("/RRContent")).Returns("physical");
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/FlushFailures");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(false);
context.Setup(x => x.User.Identity).Returns(identity.Object);
var queue = new Mock<IReducingQueue>();
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IReducingQueue>().Use(queue.Object);
});
module.HandleRRFlush(context.Object);
config.VerifySet(x => x.SpritePhysicalPath = "physical", Times.Once());
RRContainer.Current = null;
}
示例3: WillNotFlushReductionsOnFlushUrlWhenCurrentUserIsNotAuthorizedUserAndReturn401
public void WillNotFlushReductionsOnFlushUrlWhenCurrentUserIsNotAuthorizedUserAndReturn401()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(new string[] { "user1", "user2" });
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
var response = new Mock<HttpResponseBase>();
response.SetupProperty(x => x.StatusCode);
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/flush");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(true);
identity.Setup(x => x.Name).Returns("user3");
context.Setup(x => x.User.Identity).Returns(identity.Object);
context.Setup(x => x.Response).Returns(response.Object);
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.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(It.IsAny<Guid>()), Times.Never());
Assert.Equal(401, response.Object.StatusCode);
RRContainer.Current = null;
}
示例4: WillNotFlushReductionsIfNotOnFlushUrl
public void WillNotFlushReductionsIfNotOnFlushUrl()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/notflush");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(false);
context.Setup(x => x.User.Identity).Returns(identity.Object);
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.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(It.IsAny<Guid>()), Times.Never());
RRContainer.Current = null;
}
示例5: WillFlushReductionsOnFlushUrlWithTrailingSlashWhenCurrentUserIsAuthorizedUser
public void WillFlushReductionsOnFlushUrlWithTrailingSlashWhenCurrentUserIsAuthorizedUser()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(new string[] { "user1", "user2" });
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/flush/");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(true);
identity.Setup(x => x.Name).Returns("user2");
context.Setup(x => x.User.Identity).Returns(identity.Object);
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.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(Guid.Empty), Times.Once());
RRContainer.Current = null;
}
示例6: WillFlushReductionsOnFlushUrlWhenAndAuthorizedUsersIsAnonymous
public void WillFlushReductionsOnFlushUrlWhenAndAuthorizedUsersIsAnonymous(string url, string key)
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns(url);
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(false);
context.Setup(x => x.User.Identity).Returns(identity.Object);
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>();
});
var keyGuid = Guid.Parse(key);
module.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(keyGuid), Times.Once());
RRContainer.Current = null;
}
示例7: WillNotFlushReductionsOnFlushUrlWhenAuthorizedUsersIsAnonymousButBlockedByIpFilterAndReturn401
public void WillNotFlushReductionsOnFlushUrlWhenAuthorizedUsersIsAnonymousButBlockedByIpFilterAndReturn401()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
config.Setup(x => x.IpFilterList).Returns(new[] { "1.2.3.4", " 3.4.5.6" });
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
var response = new Mock<HttpResponseBase>();
response.SetupProperty(x => x.StatusCode);
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/flush");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(false);
context.Setup(x => x.User.Identity).Returns(identity.Object);
context.Setup(x => x.Response).Returns(response.Object);
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Request.UserHostAddress).Returns("10.0.0.1");
context.Setup(x => x.Request.ServerVariables).Returns(new NameValueCollection { { "HTTP_X_FORWARDED_FOR","9.9.9.9" } });
var store = new Mock<IStore>();
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<UriBuilder>();
x.For<IIpFilter>().Use<IpFilter>();
});
module.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(It.IsAny<Guid>()), Times.Never());
Assert.Equal(401, response.Object.StatusCode);
RRContainer.Current = null;
}
示例8: WillFlushReductionsOnFlushUrlWhenCurrentUserIsAuthorizedUserAndEquivalentIpv6IsInIpFilter
public void WillFlushReductionsOnFlushUrlWhenCurrentUserIsAuthorizedUserAndEquivalentIpv6IsInIpFilter()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(new string[] { "user1", "user2" });
config.Setup(x => x.IpFilterList).Returns(new[] { "3780:0:c307:0:2c45:0:81c7:9273" });
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/flush");
var identity = new Mock<IIdentity>();
identity.Setup(x => x.IsAuthenticated).Returns(true);
identity.Setup(x => x.Name).Returns("user2");
context.Setup(x => x.User.Identity).Returns(identity.Object);
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.Request.UserHostAddress).Returns("3780:0000:c307:0000:2c45:0000:81c7:9273");
var store = new Mock<IStore>();
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<UriBuilder>();
x.For<IIpFilter>().Use<IpFilter>();
});
module.HandleRRFlush(context.Object);
store.Verify(x => x.Flush(Guid.Empty), Times.Once());
RRContainer.Current = null;
}
示例9: WillFlushFailuresOnFlushFailureUrlWhenAndAuthorizedUsersIsAnonymousAndNull
public void WillFlushFailuresOnFlushFailureUrlWhenAndAuthorizedUsersIsAnonymousAndNull()
{
var module = new RequestReduceModule();
var config = new Mock<IRRConfiguration>();
config.Setup(x => x.AuthorizedUserList).Returns(RRConfiguration.Anonymous);
config.Setup(x => x.SpriteVirtualPath).Returns("/RRContent");
var context = new Mock<HttpContextBase>();
context.Setup(x => x.Request.RawUrl).Returns("/RRContent/FlushFailures");
context.Setup(x => x.Server).Returns(new Mock<HttpServerUtilityBase>().Object);
context.Setup(x => x.User).Returns(null as IPrincipal);
var queue = new Mock<IReducingQueue>();
RRContainer.Current = new Container(x =>
{
x.For<IRRConfiguration>().Use(config.Object);
x.For<IHostingEnvironmentWrapper>().Use(new Mock<IHostingEnvironmentWrapper>().Object);
x.For<IReducingQueue>().Use(queue.Object);
x.For<IUriBuilder>().Use<UriBuilder>();
x.For<IIpFilter>().Use<IpFilter>();
});
module.HandleRRFlush(context.Object);
queue.Verify(x => x.ClearFailures(), Times.Once());
RRContainer.Current = null;
}