本文整理汇总了C#中Sitecore.FakeDb.Sites.FakeSiteContext类的典型用法代码示例。如果您正苦于以下问题:C# FakeSiteContext类的具体用法?C# FakeSiteContext怎么用?C# FakeSiteContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FakeSiteContext类属于Sitecore.FakeDb.Sites命名空间,在下文中一共展示了FakeSiteContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnActionExecuting_RedirectEqualsCurrent_ShouldRedirectToRootPage
public void OnActionExecuting_RedirectEqualsCurrent_ShouldRedirectToRootPage(Database db, [Content] DbItem item, string afterLoginLink, [Frozen]IAccountsSettingsService accountsSettingsService, [Substitute]ActionExecutingContext filterContext, [Greedy]AccountsRedirectAuthenticatedAttribute redirectAuthenticatedAttribute)
{
//Arrange
var siteContext = new FakeSiteContext(new StringDictionary
{
{
"rootPath", "/sitecore/content"
},
{
"startItem", item.Name
}
}) as SiteContext;
siteContext.Database = db;
accountsSettingsService.GetPageLinkOrDefault(Arg.Any<Item>(), Templates.AccountsSettings.Fields.AfterLoginPage, Arg.Any<Item>()).Returns(afterLoginLink);
filterContext.HttpContext.Request.RawUrl.Returns(afterLoginLink);
//Act
using (new SiteContextSwitcher(siteContext))
using (new Sitecore.Security.Accounts.UserSwitcher(@"extranet\John", true))
{
redirectAuthenticatedAttribute.OnActionExecuting(filterContext);
}
//Assert
filterContext.Result.Should().BeOfType<RedirectResult>().Which.Url.Should().NotBe(afterLoginLink);
}
开发者ID:robearlam,项目名称:Habitat,代码行数:27,代码来源:AccountsRedirectAuthenticatedAttributeTests.cs
示例2: LoadProfiles_SettingsIsEmpty_ShouldReturnExistentProfilesEnumerable
public void LoadProfiles_SettingsIsEmpty_ShouldReturnExistentProfilesEnumerable([Content] Item item, CurrentInteraction currentInteraction, ITracker tracker, Profile profile)
{
var profileSettingItem = item.Add("profileSetting", new TemplateID(Templates.ProfilingSettings.ID));
var profileItem = item.Add("profile", new TemplateID(ProfileItem.TemplateID));
var provider = new ProfileProvider();
var fakeSiteContext = new FakeSiteContext(new StringDictionary
{
{
"rootPath", "/sitecore"
},
{
"startItem", profileSettingItem.Paths.FullPath.Remove(0, "/sitecore".Length)
}
});
fakeSiteContext.Database = item.Database;
using (new SiteContextSwitcher(fakeSiteContext))
{
provider.GetSiteProfiles().Count().Should().Be(0);
}
}
开发者ID:robearlam,项目名称:Habitat,代码行数:25,代码来源:ProfileProviderTests.cs
示例3: LoadProfiles_NoSetProfiles_ShouldReturnEmptyProfilesEnumerable
public void LoadProfiles_NoSetProfiles_ShouldReturnEmptyProfilesEnumerable(Database db, [Content] Item item, ITracker tracker, IProfileProvider provider)
{
//arrange
tracker.IsActive.Returns(true);
var fakeSiteContext = new FakeSiteContext(new StringDictionary
{
{
"rootPath", "/sitecore"
},
{
"startItem", item.Paths.FullPath.Remove(0, "/sitecore".Length)
}
});
fakeSiteContext.Database = db;
using (new SiteContextSwitcher(fakeSiteContext))
{
using (new TrackerSwitcher(tracker))
{
var model = new VisitInformation(provider);
model.LoadProfiles().Count().Should().Be(0);
}
}
}
开发者ID:robearlam,项目名称:Habitat,代码行数:25,代码来源:VisitInformationTests.cs
示例4: LoadProfiles_SettingWithProfiles_ShouldReturnExistentProfilesEnumerable
public void LoadProfiles_SettingWithProfiles_ShouldReturnExistentProfilesEnumerable(Db db, CurrentInteraction currentInteraction, ITracker tracker, Analytics.Tracking.Profile profile)
{
var profileItem = new DbItem("profile", ID.NewID, new TemplateID(ProfileItem.TemplateID));
db.Add(profileItem);
var profileSettingItem = new DbItem("profileSetting", ID.NewID, new TemplateID(Templates.ProfilingSettings.ID))
{
{Templates.ProfilingSettings.Fields.SiteProfiles, profileItem.ID.ToString()}
};
db.Add(profileSettingItem);
var provider = new ProfileProvider();
var fakeSiteContext = new FakeSiteContext(new StringDictionary
{
{"rootPath", "/sitecore"},
{"startItem", profileSettingItem.FullPath.Remove(0, "/sitecore".Length)}
})
{
Database = db.Database
};
using (new SiteContextSwitcher(fakeSiteContext))
{
var siteProfiles = provider.GetSiteProfiles();
siteProfiles.Count().Should().Be(1);
}
}
开发者ID:Sitecore,项目名称:Habitat,代码行数:28,代码来源:ProfileProviderTests.cs
示例5: ShouldCreateSimpleFakeSiteContext
public void ShouldCreateSimpleFakeSiteContext()
{
// arrange & act
var siteContext = new FakeSiteContext("mywebsite");
// assert
siteContext.Name.Should().Be("mywebsite");
siteContext.Database.Should().BeNull();
}
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:9,代码来源:FakeSiteContextTest.cs
示例6: ShouldCreateAdvancedFakeSiteContext
public void ShouldCreateAdvancedFakeSiteContext()
{
// arrange & act
var siteContext = new FakeSiteContext(new StringDictionary { { "name", "mywebsite" }, { "database", "web" } });
// assert
siteContext.Name.Should().Be("mywebsite");
siteContext.Database.Name.Should().Be("web");
}
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:9,代码来源:FakeSiteContextTest.cs
示例7: FakeSite
public FakeSite()
{
_fakeSiteContext = new Sitecore.FakeDb.Sites.FakeSiteContext(
new Sitecore.Collections.StringDictionary
{
{"name", "website"},
{"database", "web"}
});
_switcher = new FakeSiteContextSwitcher(_fakeSiteContext);
}
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:11,代码来源:FakeSite.cs
示例8: ShouldSwitchContextSite
public void ShouldSwitchContextSite()
{
// arrange
var site = new FakeSiteContext("mywebsite");
// act
using (new SiteContextSwitcher(site))
{
// assert
Context.Site.Name.Should().Be("mywebsite");
}
Context.Site.Should().BeNull();
}
开发者ID:dharnitski,项目名称:Sitecore.FakeDb,代码行数:14,代码来源:SiteContextSwitcherTest.cs
示例9: OnActionExecuting_NotNormalMode_ShouldNotRedirect
public void OnActionExecuting_NotNormalMode_ShouldNotRedirect(FakeSiteContext siteContext, [Substitute]ActionExecutingContext filterContext, RedirectAuthenticatedAttribute redirectAuthenticatedAttribute)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
//Act
using (new SiteContextSwitcher(siteContext))
{
redirectAuthenticatedAttribute.OnActionExecuting(filterContext);
}
//Assert
filterContext.Result.Should().BeNull();
}
开发者ID:GoranHalvarsson,项目名称:Habitat,代码行数:14,代码来源:RedirectAuthenticatedAttributeTests.cs
示例10: PageEditorError_EditMode_RenderErrorViewFriendlyMessage
public void PageEditorError_EditMode_RenderErrorViewFriendlyMessage(string errorMessage, string friendlyMessage, FakeSiteContext siteContext, [RegisterView(Constants.InfoMessageView)] IView view, HtmlHelper helper)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
//Act
MvcHtmlString result;
using (new SiteContextSwitcher(siteContext))
{
result = helper.PageEditorError(errorMessage, friendlyMessage, ID.NewID, ID.NewID);
//Assert
view.Received().Render(Arg.Is<ViewContext>(v => v.ViewData.Model.As<InfoMessage>().Type == InfoMessage.MessageType.Error), Arg.Any<TextWriter>());
}
}
开发者ID:alinulms,项目名称:Habitat,代码行数:15,代码来源:AlertHtmlHelpersTests.cs
示例11: Process_HandledException_DontSetView
public void Process_HandledException_DontSetView(FakeSiteContext siteContext, InvalidDatasourceItemExceptionProcessor processor, [Modest] ExceptionContext exceptionContext, [Substitute] ExceptionArgs exceptionArgs)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
exceptionArgs.ExceptionContext.ExceptionHandled = true;
//Act
using (new SiteContextSwitcher(siteContext))
{
processor.Process(exceptionArgs);
//Assert
exceptionArgs.ExceptionContext.Result.Should().BeOfType<EmptyResult>();
}
}
开发者ID:alinulms,项目名称:Habitat,代码行数:15,代码来源:InvalidDatasourceItemExceptionProcessorTests.cs
示例12: Get_DictionaryRootItemExists_ThrowConfigurationErrorException
public void Get_DictionaryRootItemExists_ThrowConfigurationErrorException(Db db, [Content]DbItem item, DictionaryRepository repository)
{
//Arrange
var siteContext = new FakeSiteContext(new StringDictionary()
{
["dictionaryPath"] = item.FullPath,
["database"] = "master"
});
//Assert
using (new SiteContextSwitcher(siteContext))
{
repository.Get(siteContext).Root.ID.Should().Be(item.ID);
}
}
开发者ID:GoranHalvarsson,项目名称:Habitat,代码行数:15,代码来源:DictionaryRepositoryTests.cs
示例13: Get_NotDictionaryRootItem_ThrowConfigurationErrorException
public void Get_NotDictionaryRootItem_ThrowConfigurationErrorException(Db db, DictionaryRepository repository)
{
//Arrange
var siteContext = new FakeSiteContext(new StringDictionary()
{
["dictionaryPath"] = "/sitecore/content/dictionaryPath",
["database"] = "master"
});
//Assert
using (new SiteContextSwitcher(siteContext))
{
repository.Invoking(x => x.Get(siteContext)).ShouldThrow<ConfigurationErrorsException>();
}
}
开发者ID:GoranHalvarsson,项目名称:Habitat,代码行数:15,代码来源:DictionaryRepositoryTests.cs
示例14: OnActionExecuting_NotAuthenticatedUser_ShouldNotRedirect
public void OnActionExecuting_NotAuthenticatedUser_ShouldNotRedirect(FakeSiteContext siteContext, [Substitute]ActionExecutingContext filterContext, RedirectAuthenticatedAttribute redirectAuthenticatedAttribute)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Normal);
//Act
using (new SiteContextSwitcher(siteContext))
using (new Sitecore.Security.Accounts.UserSwitcher(@"extranet\John", false))
{
redirectAuthenticatedAttribute.OnActionExecuting(filterContext);
}
//Assert
filterContext.Result.Should().BeNull();
}
开发者ID:GoranHalvarsson,项目名称:Habitat,代码行数:15,代码来源:RedirectAuthenticatedAttributeTests.cs
示例15: Logout_ShouldCallSitecoreLogout
public void Logout_ShouldCallSitecoreLogout(Database db, [Content] DbItem item, IAccountRepository repo, INotificationService ns, IAccountsSettingsService acc)
{
var fakeSite = new FakeSiteContext(new StringDictionary
{
{"rootPath", "/sitecore/content"},
{"startItem", item.Name}
}) as SiteContext;
fakeSite.Database = db;
using (new SiteContextSwitcher(fakeSite))
{
var ctrl = new AccountsController(repo, ns, acc, null, null);
ctrl.Logout();
repo.Received(1).Logout();
}
}
开发者ID:Sitecore,项目名称:Habitat,代码行数:15,代码来源:AccountsControllerTests.cs
示例16: PageEditorError_NormalMode_ReturnEmptyString
public void PageEditorError_NormalMode_ReturnEmptyString(string errorMessage, FakeSiteContext siteContext)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Normal);
//Act
MvcHtmlString result;
using (new SiteContextSwitcher(siteContext))
{
result = AlertHtmlHelpers.PageEditorError(null, errorMessage);
}
//Assert
result.ToString().Should().BeEmpty();
}
开发者ID:alinulms,项目名称:Habitat,代码行数:15,代码来源:AlertHtmlHelpersTests.cs
示例17: PageEditorError_Call_LogError
public void PageEditorError_Call_LogError(string errorMessage, FakeSiteContext siteContext, MemoryAppender appender, [RegisterView(Constants.InfoMessageView)] IView view, HtmlHelper htmlHelper)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
BasicConfigurator.Configure(appender);
//Act
using (new SiteContextSwitcher(siteContext))
{
htmlHelper.PageEditorError(errorMessage);
}
//Assert
appender.Events.Should().Contain(x => x.RenderedMessage.Contains(errorMessage));
}
开发者ID:alinulms,项目名称:Habitat,代码行数:15,代码来源:AlertHtmlHelpersTests.cs
示例18: PageEditorError_EditMode_ReturnErrorBlock
public void PageEditorError_EditMode_ReturnErrorBlock(string errorMessage, FakeSiteContext siteContext)
{
//Arrange
typeof(SiteContext).GetField("displayMode", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(siteContext, DisplayMode.Edit);
//Act
MvcHtmlString result;
using (new SiteContextSwitcher(siteContext))
{
result = HtmlHelperExtensions.PageEditorError(null, errorMessage);
}
//Assert
result.ToString().Should().Contain(errorMessage).And.StartWith("<p").And.EndWith("</p>");
}
开发者ID:BillDinger,项目名称:SCHackathon2016,代码行数:15,代码来源:HtmlHelperExtensionsTests.cs
示例19: Current_HttpContextIsntInitialized_CreateNewRepository
public void Current_HttpContextIsntInitialized_CreateNewRepository([Content]DbItem item)
{
//Arrange
var siteContext = new FakeSiteContext(new StringDictionary()
{
["dictionaryPath"] = item.FullPath,
["database"] = "master"
});
HttpContext.Current = null;
using (new SiteContextSwitcher(siteContext))
{
//Assert
DictionaryPhraseRepository.Current.Should().BeOfType<DictionaryPhraseRepository>();
}
}
开发者ID:GoranHalvarsson,项目名称:Habitat,代码行数:16,代码来源:DictionaryPhraseRepositoryCacheTests.cs
示例20: Logout_ShouldRedirectUserToHomePage
public void Logout_ShouldRedirectUserToHomePage(Database db, [Content] DbItem item, IAccountRepository repo, INotificationService ns, IAccountsSettingsService acc)
{
var fakeSite = new FakeSiteContext(new StringDictionary
{
{"rootPath", "/sitecore/content"},
{"startItem", item.Name}
}) as SiteContext;
fakeSite.Database = db;
Language.Current = Language.Invariant;
using (new SiteContextSwitcher(fakeSite))
{
var ctrl = new AccountsController(repo, ns, acc, null, null);
var result = ctrl.Logout();
result.Should().BeOfType<RedirectResult>().Which.Url.Should().Be("/");
}
}
开发者ID:Sitecore,项目名称:Habitat,代码行数:17,代码来源:AccountsControllerTests.cs
注:本文中的Sitecore.FakeDb.Sites.FakeSiteContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论