Skip to content

Commit

Permalink
Merge pull request #7 from pveller/master
Browse files Browse the repository at this point in the history
Add /sitecore/system and /sitecore/media library items as part of initial DataStorage setup
  • Loading branch information
sshushliapin committed May 6, 2014
2 parents 8b0f147 + 8707187 commit efeb582
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using FluentAssertions;
using NSubstitute;
using Sitecore.Data;
using Sitecore.Data.DataProviders;
using Sitecore.FakeDb.Data.DataProviders;
using Sitecore.FakeDb.Data.Engines;
using Sitecore.Reflection;
Expand Down Expand Up @@ -115,6 +116,20 @@ public void ShouldSetDataStorage()
this.dataProvider.DataStorage.Should().Be(ds);
}

[Fact]
private void ShouldSupportGetLanguagesAndReturnOne()
{
// arrange
var db = this.dataStorage.Database;

// act
var langs = this.dataProvider.GetLanguages(new CallContext(db.DataManager, db.GetDataProviders().Count()));

// assert
langs.Should().HaveCount(1);
langs.First().Name.Should().Be("en");
}

private DbTemplate CreateTestTemplateInDataStorage()
{
var templateId = ID.NewID;
Expand Down
6 changes: 6 additions & 0 deletions Source/Sitecore.FakeDb.Tests/Data/DataStorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class DataStorageTest

private const string ItemIdsTemplateRoot = "{3C1715FE-6A13-4FCF-845F-DE308BA9741D}";

private const string ItemIdsSystemRoot = "{13D6D6C6-C50B-4BBD-B331-2B04F1A58F21}";

private const string ItemIdsMediaLibraryRoot = "{3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1}";

private const string TemplateIdsTemplate = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}";

private const string ItemIdsTemplateSection = "{E269FBB5-3750-427A-9149-7AA950B49301}";
Expand All @@ -42,6 +46,8 @@ public DataStorageTest()
[InlineData(ItemIdsRootId, "sitecore", TemplateIdSitecore, RootParentId, "/sitecore")]
[InlineData(ItemIdsContentRoot, "content", TemplateIdMainSection, ItemIdsRootId, "/sitecore/content")]
[InlineData(ItemIdsTemplateRoot, "templates", TemplateIdMainSection, ItemIdsRootId, "/sitecore/templates")]
[InlineData(ItemIdsSystemRoot, "system", TemplateIdMainSection, ItemIdsRootId, "/sitecore/system")]
[InlineData(ItemIdsMediaLibraryRoot, "media library", TemplateIdMainSection, ItemIdsRootId, "/sitecore/media library")]
[InlineData(TemplateIdsTemplate, "Template", TemplateIdsTemplate, ItemIdsTemplateRoot, "/sitecore/templates/template")]
[InlineData(ItemIdsTemplateSection, "Template section", TemplateIdsTemplate, ItemIdsTemplateRoot, "/sitecore/templates/template section")]
[InlineData(ItemIdsTemplateField, "Template field", TemplateIdsTemplate, ItemIdsTemplateRoot, "/sitecore/templates/template field")]
Expand Down
6 changes: 6 additions & 0 deletions Source/Sitecore.FakeDb/Data/DataProviders/FakeDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Sitecore.Data.DataProviders;
using Sitecore.Data.Templates;
using Sitecore.FakeDb.Data.Engines;
using Sitecore.Globalization;
using CallContext = Sitecore.Data.DataProviders.CallContext;

public class FakeDataProvider : DataProvider, IRequireDataStorage
Expand Down Expand Up @@ -60,5 +61,10 @@ public override TemplateCollection GetTemplates(CallContext context)

return templates;
}

public override LanguageCollection GetLanguages(CallContext context)
{
return new LanguageCollection { Language.Parse("en") };
}
}
}
6 changes: 6 additions & 0 deletions Source/Sitecore.FakeDb/Data/Engines/DataStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public class DataStorage

private const string TemplatesItemName = "templates";

private const string SystemItemName = "system";

private const string MediaLibraryItemName = "media library";

public const string TemplateItemName = "Template";

public const string TemplateSectionItemName = "Template section";
Expand Down Expand Up @@ -153,6 +157,8 @@ protected virtual void FillDefaultFakeItems()
this.FakeItems.Add(ItemIDs.RootID, new DbItem(SitecoreItemName, ItemIDs.RootID, RootTemplateId) { ParentID = ID.Null, FullPath = "/sitecore" });
this.FakeItems.Add(ItemIDs.ContentRoot, new DbItem(ContentItemName, ItemIDs.ContentRoot, TemplateIDs.MainSection) { ParentID = ItemIDs.RootID, FullPath = "/sitecore/content" });
this.FakeItems.Add(ItemIDs.TemplateRoot, new DbItem(TemplatesItemName, ItemIDs.TemplateRoot, TemplateIDs.MainSection) { ParentID = ItemIDs.RootID, FullPath = "/sitecore/templates" });
this.FakeItems.Add(ItemIDs.SystemRoot, new DbItem(SystemItemName, ItemIDs.SystemRoot, TemplateIDs.MainSection) { ParentID = ItemIDs.RootID, FullPath = "/sitecore/system"});
this.FakeItems.Add(ItemIDs.MediaLibraryRoot, new DbItem(MediaLibraryItemName, ItemIDs.MediaLibraryRoot, TemplateIDs.MainSection) { ParentID = ItemIDs.RootID, FullPath = "/sitecore/media library" });

// TODO: Move 'Template' item to proper directory to correspond Sitecore structure.
this.FakeItems.Add(TemplateIDs.Template, new DbItem(TemplateItemName, TemplateIDs.Template, TemplateIDs.Template) { ParentID = ItemIDs.TemplateRoot, FullPath = "/sitecore/templates/template" });
Expand Down

0 comments on commit efeb582

Please sign in to comment.