当前位置: 首页>>代码示例>>C#>>正文


C# FakeDb.DbItem类代码示例

本文整理汇总了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);
      }
    }
开发者ID:Sitecore,项目名称:Habitat,代码行数:28,代码来源:ProfileProviderTests.cs

示例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();
    }
开发者ID:kamsar,项目名称:Habitat,代码行数:7,代码来源:GetFieldsToEditServiceTests.cs

示例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);
    }
开发者ID:robearlam,项目名称:Habitat,代码行数:26,代码来源:LanguageRepositoryTests.cs

示例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);
    }
开发者ID:kamsar,项目名称:Habitat,代码行数:27,代码来源:LanguageRepositoryTests.cs

示例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);
 }
开发者ID:alinulms,项目名称:Habitat,代码行数:28,代码来源:DatasourceProviderTests.cs

示例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) });
      }
    }
开发者ID:zyq524,项目名称:Habitat,代码行数:30,代码来源:BehaviorProfileDecoratorTests.cs

示例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();
		}
开发者ID:OlegJytnik,项目名称:Rainbow,代码行数:8,代码来源:ItemDataTests.cs

示例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();
		}
开发者ID:OlegJytnik,项目名称:Rainbow,代码行数:8,代码来源:ItemDataTests.cs

示例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);
 }
开发者ID:mikeedwards83,项目名称:Habitat,代码行数:8,代码来源:ConfigurationDatasourceProviderTests.cs

示例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);
 }
开发者ID:robearlam,项目名称:Habitat,代码行数:9,代码来源:SiteContextTests.cs

示例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);
		}
开发者ID:OlegJytnik,项目名称:Rainbow,代码行数:9,代码来源:ItemDataTests.cs

示例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();
 }
开发者ID:alinulms,项目名称:Habitat,代码行数:10,代码来源:GetDataSourceLocationAndTemplateFromSiteTests.cs

示例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);
    }
开发者ID:alinulms,项目名称:Habitat,代码行数:10,代码来源:SiteContextTests.cs

示例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);
    }
开发者ID:kamsar,项目名称:Habitat,代码行数:10,代码来源:GetFieldsToEditServiceTests.cs

示例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();
 }
开发者ID:mikeedwards83,项目名称:Habitat,代码行数:11,代码来源:GetDataSourceLocationAndTemplateFromSiteTests.cs


注:本文中的Sitecore.FakeDb.DbItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。