本文整理汇总了C#中Sitecore.FakeDb.DbItem类的典型用法代码示例。如果您正苦于以下问题:C# DbItem类的具体用法?C# DbItem怎么用?C# DbItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbItem类属于Sitecore.FakeDb命名空间,在下文中一共展示了DbItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: GetFieldsToEdit_ItemHasNoCustomFields_ReturnEmptyString
public void GetFieldsToEdit_ItemHasNoCustomFields_ReturnEmptyString(Db db, DbItem item)
{
db.Add(item);
var testItem = db.GetItem(item.ID);
GetFieldsToEditService.GetFieldsToEdit(testItem).Should().BeEmpty();
}
示例3: GetSupportedLanguages_ShouldReturlListOfSupportedLanguages
public void GetSupportedLanguages_ShouldReturlListOfSupportedLanguages(Db db, DbItem item , string rootName)
{
var contextItemId = ID.NewID;
var rootId = ID.NewID;
var template = new DbTemplate();
template.BaseIDs = new[]
{
Foundation.Multisite.Templates.Site.ID,
Templates.LanguageSettings.ID
};
var languageItem = new DbItem("en");
db.Add(languageItem);
db.Add(new DbTemplate(Foundation.Multisite.Templates.Site.ID));
db.Add(new DbTemplate(Templates.LanguageSettings.ID) {Fields = { { Templates.LanguageSettings.Fields.SupportedLanguages, languageItem.ID.ToString()} }});
db.Add(template);
var rootItem = new DbItem(rootName, rootId, template.ID){ new DbField(Templates.LanguageSettings.Fields.SupportedLanguages) { {"en", languageItem.ID.ToString()} } };
rootItem.Add(item);
db.Add(rootItem);
var contextItem = db.GetItem(item.ID);
Sitecore.Context.Item = contextItem;
var supportedLanguages = LanguageRepository.GetSupportedLanguages();
supportedLanguages.Count().Should().BeGreaterThan(0);
}
示例4: GetSupportedLanguages_NoneSelected_ShouldReturnEmptyList
public void GetSupportedLanguages_NoneSelected_ShouldReturnEmptyList(Db db, [Content] DbTemplate template, DbItem item, string rootName)
{
template.BaseIDs = new[]
{
Templates.Site.ID, Feature.Language.Templates.LanguageSettings.ID
};
var languageItem = new DbItem("en");
db.Add(languageItem);
var siteRootItem = new DbItem(rootName, ID.NewID, template.ID)
{
new DbField(Feature.Language.Templates.LanguageSettings.Fields.SupportedLanguages)
{
{
"en", ""
}
}
};
siteRootItem.Add(item);
db.Add(siteRootItem);
var contextItem = db.GetItem(item.ID);
Context.Item = contextItem;
var supportedLanguages = LanguageRepository.GetSupportedLanguages();
supportedLanguages.Count().Should().Be(0);
}
示例5: GetDatasources_LocationSetByRelativePath_ShouldReturnSourcesFromSettingItem
public void GetDatasources_LocationSetByRelativePath_ShouldReturnSourcesFromSettingItem([Frozen]ISiteSettingsProvider siteSettingsProvider, [Greedy]DatasourceProvider provider, string name, string contextItemName, Db db, string settingItemName, Item item, string sourceRootName)
{
var contextItemId = ID.NewID;
var contextDbItem = new DbItem(contextItemName.Replace("-", String.Empty), contextItemId);
var rootName = sourceRootName.Replace("-", string.Empty);
var sourceRoot = new DbItem(rootName);
contextDbItem.Add(sourceRoot);
db.Add(contextDbItem);
var settingId = ID.NewID;
var settingDbItem = new DbItem(settingItemName.Replace("-", String.Empty), settingId, Templates.DatasourceConfiguration.ID)
{
new DbField(Templates.DatasourceConfiguration.Fields.DatasourceLocation)
{
{
"en", $"./{rootName}"
}
}
};
var contextItem = db.GetItem(contextItemId);
db.Add(settingDbItem);
var sourceRootItem = db.GetItem(sourceRoot.ID);
var settingItem = db.GetItem(settingId);
siteSettingsProvider.GetSetting(Arg.Any<Item>(), Arg.Any<string>(), Arg.Any<string>()).Returns(settingItem);
var sources = provider.GetDatasourceLocations(contextItem, name);
sources.Should().NotBeNull();
sources.Should().Contain(sourceRootItem);
}
示例6: GetEnumerator_Call_ReturnScoresWithKeyName
public void GetEnumerator_Call_ReturnScoresWithKeyName(Db db, ID keyId1, ID keyId2, DbItem profileItem, IBehaviorProfileContext behaviorProfile)
{
//Arrange
using (new SecurityDisabler())
{
profileItem.Add(new DbItem("Key1", keyId1, ProfileKeyItem.TemplateID)
{
{ProfileKeyItem.FieldIDs.NameField,"key1name" }
});
profileItem.Add(new DbItem("Key2", keyId2, ProfileKeyItem.TemplateID)
{
{ProfileKeyItem.FieldIDs.NameField,"key2name" }
});
db.Add(profileItem);
var item = db.GetItem(profileItem.FullPath);
var profile = new ProfileItem(item);
var behaviorScores = new List<KeyValuePair<ID, float>>() { new KeyValuePair<ID, float>(keyId1, 10), new KeyValuePair<ID, float>(keyId2, 20) };
behaviorProfile.Scores.Returns(behaviorScores);
var behaviorProfileDecorator = new BehaviorProfileDecorator(profile, behaviorProfile);
//Act
var result = behaviorProfileDecorator.ToList();
//Assert
result.Should().BeEquivalentTo(new[] { new KeyValuePair<string, float>("key1name", 10), new KeyValuePair<string, float>("key2name", 20) });
}
}
示例7: SharedFields_ReturnsExpectedValues
public void SharedFields_ReturnsExpectedValues(Db db, DbItem item, Guid fieldId)
{
item.Fields.Add(new DbField(new ID(fieldId)) { Shared = true, Value = "test field" });
var dbItem = db.CreateItem(item);
new ItemData(dbItem).SharedFields.Any(f => f.FieldId == fieldId).Should().BeTrue();
}
示例8: SharedFields_DoesNotReturnVersionedValues
public void SharedFields_DoesNotReturnVersionedValues(Db db, DbItem item, Guid fieldId)
{
item.Fields.Add(new DbField(new ID(fieldId)) { Value = "test field" });
var dbItem = db.CreateItem(item);
new ItemData(dbItem).SharedFields.Any(f => f.FieldId == fieldId).Should().BeFalse();
}
示例9: GetDataSources_SiteInfoIsNull_ShouldReturnNull
public void GetDataSources_SiteInfoIsNull_ShouldReturnNull([Frozen]ISettingsProvider settingsProvider, [Greedy]ConfigurationDatasourceProvider provider, string settingName, Item contextItem, DbItem sourceDbItem, Db db)
{
provider.Database = db.Database;
db.Add(sourceDbItem);
settingsProvider.GetCurrentSiteInfo(Arg.Any<Item>()).Returns((SiteInfo)null);
var sources = provider.GetDatasources(settingName, contextItem);
sources.Should().HaveCount(0);
}
示例10: GetSiteDefinition_ItemInSiteHierarcy_ShouldReturnHierarchicalSiteDefinition
public void GetSiteDefinition_ItemInSiteHierarcy_ShouldReturnHierarchicalSiteDefinition(SiteContext siteContext, DbItem item , Db db, string siteName)
{
var siteDefinitionId = ID.NewID;
db.Add(new DbItem(siteName, siteDefinitionId, Templates.Site.ID) {item});
var contextItem = db.GetItem(item.ID);
var definitionItem = db.GetItem(siteDefinitionId);
var siteDefinition = siteContext.GetSiteDefinition(contextItem);
siteDefinition.Item.ID.ShouldBeEquivalentTo(definitionItem.ID);
}
示例11: BranchId_ReturnsExpectedValue
public void BranchId_ReturnsExpectedValue(Db db, DbItem item, Guid branchId)
{
item.BranchId = new ID(branchId);
db.Add(item);
var dbItem = db.GetItem(item.ID);
new ItemData(dbItem).BranchId.Should().Be(branchId);
}
示例12: Process_SiteSettingNameHasWrongFirmat_SourcesAndTemplateAreNotSet
public void Process_SiteSettingNameHasWrongFirmat_SourcesAndTemplateAreNotSet(GetDatasourceLocationAndTemplateFromSite processor, DbItem renderingItem, Db db, string settingName)
{
renderingItem.Add(new DbField("Datasource Location") { { "en", $"site:{settingName}" } });
db.Add(renderingItem);
var rendering = db.GetItem(renderingItem.ID);
var args = new GetRenderingDatasourceArgs(rendering);
processor.Process(args);
args.DatasourceRoots.Count.Should().Be(0);
args.Prototype.Should().BeNull();
}
示例13: GetSiteDefinition_ProviderReturnsEmpty_ShouldReturnNull
public void GetSiteDefinition_ProviderReturnsEmpty_ShouldReturnNull(ISiteDefinitionsProvider provider, DbItem item, Db db, string siteName)
{
db.Add(item);
var contextItem = db.GetItem(item.ID);
provider.GetContextSiteDefinition(Arg.Any<Item>()).Returns((SiteDefinition)null);
var siteContext = new SiteContext(provider);
siteContext.GetSiteDefinition(contextItem).ShouldBeEquivalentTo(null);
}
示例14: GetFieldsToEdit_ItemHasFields_ReturnFields
public void GetFieldsToEdit_ItemHasFields_ReturnFields(Db db, DbItem item, DbField field1, DbField field2)
{
item.Add(field1);
item.Add(field2);
db.Add(item);
var testItem = db.GetItem(item.ID);
var expectedResult = new [] {field1.Name + "|" + field2.Name, field2.Name + "|" + field1.Name};
GetFieldsToEditService.GetFieldsToEdit(testItem).Should().BeOneOf(expectedResult);
}
示例15: Process_DatasourceProvidersAreNull_SourcesAndTemplateAreNotSet
public void Process_DatasourceProvidersAreNull_SourcesAndTemplateAreNotSet([Frozen]DatasourceProviderFactory factory, GetDatasourceLocationAndTemplateFromSite processor, DbItem renderingItem, Db db, string settingName)
{
var setting = settingName.Replace("-", string.Empty);
renderingItem.Add(new DbField("Datasource Location") { {"en", $"site:{setting}"} });
db.Add(renderingItem);
var rendering = db.GetItem(renderingItem.ID);
var args = new GetRenderingDatasourceArgs(rendering);
processor.Process(args);
args.DatasourceRoots.Count.Should().Be(0);
args.Prototype.Should().BeNull();
}