public override void Delete(DbItem item) { if (!IsAuthenticated) throw AuthException.NotLoggedIn(); _dataService.Delete(item); }
public void ShouldMoveItemToNewDestination(MoveItemCommand sut, GetParentCommandPrototype getParentCommand, Item item, Item destination, ID parentId, DataStorageSwitcher switcher) { // arrange sut.Database.Engines.DataEngine.Commands.GetParentPrototype = getParentCommand; var fakeItem = new DbItem("item", item.ID) { ParentID = parentId }; var fakeParent = new DbItem("parent", parentId) { Children = { fakeItem } }; var fakeDestination = new DbItem("destination", destination.ID) { FullPath = "/new destination path" }; sut.DataStorage.GetFakeItem(item.ID).Returns(fakeItem); sut.DataStorage.GetFakeItem(parentId).Returns(fakeParent); sut.DataStorage.GetFakeItem(destination.ID).Returns(fakeDestination); sut.Initialize(item, destination); // act var result = (bool)ReflectionUtil.CallMethod(sut, "DoExecute"); // assert result.Should().BeTrue(); fakeItem.ParentID.Should().Be(destination.ID); fakeItem.FullPath.Should().Be("/new destination path/item"); fakeParent.Children.Should().NotContain(fakeItem); fakeDestination.Children.Should().Contain(fakeItem); }
public void ShouldDeleteItemDescendants() { // arrange var itemId = ID.NewID; var desc1Id = ID.NewID; var desc2Id = ID.NewID; var item = new DbItem("item", itemId); var desc1 = new DbItem("descendant1", desc1Id); var desc2 = new DbItem("descendant2", desc2Id); item.Children.Add(desc1); desc1.Children.Add(desc2); this.dataStorage.FakeItems.Add(itemId, item); this.dataStorage.FakeItems.Add(desc1Id, desc1); this.dataStorage.FakeItems.Add(desc2Id, desc2); this.command.Initialize(ItemHelper.CreateInstance(this.database, itemId), ID.NewID); // act this.command.DoExecute(); // assert this.dataStorage.FakeItems.Should().NotContainKey(desc1Id); this.dataStorage.FakeItems.Should().NotContainKey(desc2Id); }
protected override Item DoExecute() { var dataStorage = this.innerCommand.DataStorage; var item = new DbItem(this.CopyName, this.CopyId, this.Source.TemplateID) { ParentID = this.Destination.ID }; dataStorage.AddFakeItem(item); var fakeItem = dataStorage.GetFakeItem(this.Source.ID); var fakeCopy = dataStorage.GetFakeItem(this.CopyId); this.CopyFields(fakeItem, fakeCopy); var copy = dataStorage.GetSitecoreItem(this.CopyId, this.Source.Language); if (!this.Deep) { return copy; } foreach (Item child in this.Source.Children) { ItemManager.CopyItem(child, copy, this.Deep, child.Name, ID.NewID); } return copy; }
public DbItem Copy(bool includeId = false) { var item = new DbItem(Value, RefId); if (includeId) item.Id = Id; return item; }
public virtual Item Create(string itemName, ID itemId, ID templateId, Database database, Item destination) { var language = Language.Current; if (this.DataStorage.GetFakeItem(itemId) != null) { return this.DataStorage.GetSitecoreItem(itemId, language); } var fieldList = this.DataStorage.GetFieldList(templateId, itemName); var item = ItemHelper.CreateInstance(itemName, itemId, templateId, fieldList, database, language); var parentItem = this.DataStorage.GetFakeItem(destination.ID); var fullPath = parentItem.FullPath + "/" + itemName; var dbitem = new DbItem(itemName, itemId, templateId) { ParentID = destination.ID, FullPath = fullPath }; if (this.dataStorage.GetFakeTemplate(templateId) != null) { foreach (var field in this.dataStorage.GetFakeTemplate(templateId).Fields) { // TODO: Introduce field clonning. dbitem.Fields.Add(new DbField(field.Name) { ID = field.ID }); } } this.DataStorage.FakeItems.Add(itemId, dbitem); this.DataStorage.GetFakeItem(destination.ID).Children.Add(dbitem); return item; }
public override void Delete(DbItem item) { if (item.Id <= 0) return; Execute(string.Format("DELETE FROM " + _itemsTable + " WHERE id = {0}", AsValueNullable(item.Id))); }
public void ShouldMoveItemToNewDestination() { // arrange var itemId = ID.NewID; var parentId = ID.NewID; var destinationId = ID.Null; var item = ItemHelper.CreateInstance(this.database, "item", itemId); var destination = ItemHelper.CreateInstance(this.database, destinationId); var getParentCommand = new FakeGetParentCommand(); this.database.Engines.DataEngine.Commands.GetParentPrototype = getParentCommand; var fakeItem = new DbItem("item", itemId) { ParentID = parentId }; var fakeParent = new DbItem("parent", parentId) { Children = { fakeItem } }; var fakeDestination = new DbItem("destination", destinationId) { FullPath = "/new destination path" }; this.dataStorage.GetFakeItem(itemId).Returns(fakeItem); this.dataStorage.GetFakeItem(parentId).Returns(fakeParent); this.dataStorage.GetFakeItem(destinationId).Returns(fakeDestination); var command = new OpenMoveItemCommand(); command.Initialize(item, destination); command.Initialize(this.dataStorage); // act var result = command.DoExecute(); // assert result.Should().BeTrue(); fakeItem.ParentID.Should().Be(destinationId); fakeItem.FullPath.Should().Be("/new destination path/item"); fakeParent.Children.Should().NotContain(fakeItem); fakeDestination.Children.Should().Contain(fakeItem); }
public void ShouldReturnItemChildren() { // arrange var dbchild1 = new DbItem("child1"); var dbchild2 = new DbItem("child2"); var dbitem = new DbItem("item") { dbchild1, dbchild2 }; var child1 = ItemHelper.CreateInstance(this.database); var child2 = ItemHelper.CreateInstance(this.database); var item = ItemHelper.CreateInstance(this.database, dbitem.ID); this.dataStorage.GetFakeItem(dbitem.ID).Returns(dbitem); this.dataStorage.GetSitecoreItem(dbchild1.ID, item.Language).Returns(child1); this.dataStorage.GetSitecoreItem(dbchild2.ID, item.Language).Returns(child2); var command = new OpenGetChildrenCommand { Engine = new DataEngine(this.database) }; command.Initialize(item); command.Initialize(this.dataStorage); // act var children = command.DoExecute(); // assert children[0].Should().Be(child1); children[1].Should().Be(child2); }
protected override Item DoExecute() { var item = new DbItem(this.ItemName, this.NewId, this.TemplateId) { ParentID = this.Destination.ID }; this.dataStorage.AddFakeItem(item); return this.dataStorage.GetSitecoreItem(this.NewId); }
private static void AddStatisticsFields(DbItem item, string date, string user) { item.Fields.Add(new DbField("__Created", FieldIDs.Created) { Value = date }); item.Fields.Add(new DbField("__Created by", FieldIDs.CreatedBy) { Value = user }); item.Fields.Add(new DbField("__Revision", FieldIDs.Revision) { Value = ID.NewID.ToString() }); item.Fields.Add(new DbField("__Updated", FieldIDs.Updated) { Value = date }); item.Fields.Add(new DbField("__Updated by", FieldIDs.UpdatedBy) { Value = user }); }
public void ShouldCheckIfDoesNotContain(DbItem item, DbItemChildCollection sut) { // act var result = sut.Contains(item); // assert result.Should().BeFalse(); }
public void ShouldAdd(DbItem item, DbItemChildCollection sut) { // act sut.Add(item); // assert sut.Count.Should().Be(1); }
public void ShouldResolvePath(string path, ResolvePathCommand sut, DbItem item) { item.FullPath = "/sitecore/content/home"; sut.DataStorage.GetFakeItems().Returns(new[] { item }); sut.Initialize(path); ReflectionUtil.CallMethod(sut, "DoExecute").Should().Be(item.ID); }
public void ShouldSetItemAccess() { // arrange var item = new DbItem("home") { Access = new DbItemAccess { CanRead = false } }; // act & assert item.Access.CanRead.Should().BeFalse(); }
protected virtual void UpdateFields(DbItem fakeItem) { foreach (Field field in this.Item.Fields) { Assert.IsTrue(fakeItem.Fields.InnerFields.ContainsKey(field.ID), "Item field not found. Item: '{0}', '{1}'; field: '{2}'.", Item.Name, Item.ID, field.ID); fakeItem.Fields[field.ID].Value = field.Value; } }
public void ShouldCreateNewItemAccess() { // arrange var item = new DbItem("home"); // act item.Access.Should().BeOfType<DbItemAccess>(); }
public void ShouldCopyTo([Frozen]DbItem item, [Greedy]DbItemChildCollection sut) { var array = new DbItem[3]; sut.CopyTo(array, 0); array.Should().Contain(item); }
protected override Item DoExecute() { var item = new DbItem(this.ItemName, this.ItemId, this.TemplateId) { ParentID = this.Destination.ID }; this.dataStorage.AddFakeItem(item); item.RemoveVersion(Language.Current.Name); return this.dataStorage.GetSitecoreItem(this.ItemId); }
public AddDbItemArgs(DbItem item, DataStorage dataStorage) { Assert.ArgumentNotNull(item, "item"); Assert.ArgumentNotNull(dataStorage, "dataStorage"); this.item = item; this.dataStorage = dataStorage; }
public void ShouldAddFields() { // arrange var item = new DbItem("home") { { "Title", "Welcome!" } }; // act & assert item.Fields.Should().ContainSingle(f => f.Name == "Title" && f.Value == "Welcome!"); }
public void ChangeTemplateThrowsIfNoTargetTemplateFound([Greedy]FakeDataProvider sut, ItemDefinition def, TemplateChangeList changes, DbItem item) { sut.DataStorage.GetFakeItem(def.ID).Returns(item); Action action = () => sut.ChangeTemplate(def, changes, null); action.ShouldThrow<InvalidOperationException>() .WithMessage("Unable to change item template. The target template is not found."); }
public override void Insert(DbItem item) { var request = new ObjectTcpMessage<DbItem>(TcpRequestType.InsertItem); request.Add(item); var response = Client.SendAndReceive<DbItem>(request); var responseItem = response.Item; if (responseItem != null) item.Id = responseItem.Id; }
protected override Item DoExecute() { var dataStorage = this.innerCommand.DataStorage; var item = new DbItem(this.ItemName, this.ItemId, this.TemplateId) { ParentID = this.Destination.ID }; dataStorage.AddFakeItem(item); item.VersionsCount.Clear(); return dataStorage.GetSitecoreItem(this.ItemId); }
public void ShouldGenerateNewIdsIfNotSet() { // arrange var item = new DbItem("my item"); // act & assert item.ID.Should().NotBeNull(); item.TemplateID.Should().NotBeNull(); }
protected virtual void CopyFields(DbItem source, DbItem copy) { Assert.ArgumentNotNull(source, "source"); Assert.ArgumentNotNull(copy, "copy"); foreach (var field in source.Fields) { this.CopyField(field, copy); } }
protected void AddToCache (DbItem item) { if (item_cache.Contains (item.Id)) item_cache.Remove (item.Id); if (cache_is_immortal) item_cache.Add (item.Id, item); else item_cache.Add (item.Id, new WeakReference (item)); }
public override void Insert(DbItem item) { lock (_lockObject) { if (item.Id == 0) item.Id = _itemIdGenerator.Get(); _items.AddLast(item); } }
public void ShouldResolveFirstItemId(ResolvePathCommand sut, DbItem item1, DbItem item2) { const string path = "/sitecore/content/home"; item1.FullPath = path; item2.FullPath = path; sut.DataStorage.GetFakeItems().Returns(new[] { item1, item2 }); sut.Initialize(path); ReflectionUtil.CallMethod(sut, "DoExecute").Should().Be(item1.ID); }
public void ShouldSetParentItemForBranches() { // arrange var item = new DbItem("sample branch", ID.NewID, TemplateIDs.BranchTemplate); // act this.processor.Process(new AddDbItemArgs(item, new DataStorage())); // assert item.ParentID.Should().Be(ItemIDs.BranchesRoot); }
public async Task <ViewItem> Create(InputItem item) { var newItem = new DbItem() { id = 0, text = item.text, isPerformed = false }; context.items.Add(newItem); await context.SaveChangesAsync(); return(mapper.Map <ViewItem>(newItem)); }
public void ShouldSetSitecoreContentFullPathByDefault() { // arrange var item = new DbItem("home"); // act using (new Db { item }) { // asert item.FullPath.Should().Be("/sitecore/content/home"); } }
public void ShouldSetSitecoreContentParentIdByDefault() { // arrange var item = new DbItem("home"); // act using (new Db { item }) { // assert item.ParentID.Should().Be(ItemIDs.ContentRoot); } }
// [Fact] public void FormatRenderingParameters_Parameters_ProcessedLowerCaseParameterKeys() { var configuration = Substitute.For <IConfiguration>(); var renderingConfiguration = Substitute.For <IRenderingConfiguration>(); var renderingItem = new DbItem("renderingItem"); using (var db = new Db { renderingItem }) { var args = new RenderJsonRenderingArgs { RenderingConfiguration = renderingConfiguration, Rendering = new Rendering { RenderingItem = db.GetItem(renderingItem.ID) }, Result = new RenderedJsonRendering { RenderingParams = new Dictionary <string, string> { { "Param1", "Value1" }, { "Param 2", "Value 2" }, { "notChanged", "1" } } } }; var likesContextExtension = new FormatRenderingParams(configuration); likesContextExtension.Process(args); Assert.NotNull(args.Result); var renderingParams = args.Result.RenderingParams; Assert.NotNull(renderingParams); Assert.Equal(3, renderingParams.Count); Assert.Contains(renderingParams, x => (x.Key == "param1") && (x.Value == "Value1")); Assert.Contains(renderingParams, x => (x.Key == "param2") && (x.Value == "Value 2")); Assert.Contains(renderingParams, x => (x.Key == "notChanged") && (x.Value == "1")); } }
public void ShouldReturnFalseIfNoChildren(HasChildrenCommand sut, Item item, DbItem fakeItemWithoutChildren) { // arrange sut.DataStorage.GetSitecoreItem(item.ID, item.Language).Returns(item); sut.DataStorage.GetFakeItem(item.ID).Returns(fakeItemWithoutChildren); sut.Initialize(item); // act var result = (bool)ReflectionUtil.CallMethod(sut, "DoExecute"); // assert result.Should().BeFalse(); }
public void ShouldGetItemDefinition([Greedy] FakeDataProvider sut, DbItem item, CallContext context) { // arrange sut.DataStorage.GetFakeItem(item.ID).Returns(item); // act var definition = sut.GetItemDefinition(item.ID, context); // assert definition.ID.Should().Be(item.ID); definition.Name.Should().Be(item.Name); definition.TemplateID.Should().Be(item.TemplateID); definition.BranchId.Should().Be(ID.Null); }
public void ShouldNotChangeParentIdIfSet() { var parentId = ID.NewID; var item = new DbItem("sample branch") { ParentID = parentId }; // act this.processor.Process(new AddDbItemArgs(item, new DataStorage(Database.GetDatabase("master")))); // assert item.ParentID.Should().Be(parentId); }
public void TestCreateDirectoryInfo() { DBTree tree = new DBTree(); DirectoryInfo d = new DirectoryInfo(@"data"); TreeViewItem item; item = tree.CreateDirectoryNode(d); TreeViewItem subItem = (TreeViewItem)item.Items[0]; DbItem value = (DbItem)subItem.Tag; string filename = Directory.GetCurrentDirectory() + @"\data\test.csm"; Assert.AreEqual(filename, value.fileName); Assert.AreEqual(false, value.isDir); }
public void ShouldResolveFirstItemId( [Greedy] FakeDataProvider sut, DbItem item1, DbItem item2, CallContext context) { const string path = "/sitecore/content/home"; item1.FullPath = path; item2.FullPath = path; sut.DataStorage.GetFakeItems().Returns(new[] { item1, item2 }); sut.ResolvePath(path, context).Should().Be(item1.ID); }
public void Add(int id, DbItem dbItem) { if (!dbItems.ContainsKey(id)) { Dictionary <byte, DbItem> blockItems = new Dictionary <byte, DbItem>(); blockItems.Add(dbItem.bBlockType, dbItem); dbItems.Add(id, blockItems); } else { dbItems[id].Add(dbItem.bBlockType, dbItem); } }
public void ShouldNotSetWorkflowIfNoDefaultWorkflowOnTemplate( SetWorkflow sut, DbItem item, DbTemplate template, [Substitute] DataStorage dataStorage, string workflowId) { dataStorage.GetFakeTemplate(item.TemplateID).Returns(template); var args = new AddDbItemArgs(item, dataStorage); sut.Process(args); item.Fields.ContainsKey(FieldIDs.Workflow).Should().BeFalse(); }
public void ShouldUpdateBranchId(SaveItemCommand sut, DbItem item, ID branchId, FieldList fields, Language language) { // arrange sut.DataStorage.GetFakeItem(item.ID).Returns(item); var updatedItem = ItemHelper.CreateInstance(sut.Database, "updated item", item.ID, ID.NewID, branchId, fields, language, new Version(0)); sut.Initialize(updatedItem); // act ReflectionUtil.CallMethod(sut, "DoExecute"); // assert item.BranchId.Should().Be(branchId); }
private User Materialize(ClassifierType type, DbItem dbItem) { var item = base.Materialize(type, dbItem.Classifier); var dbUser = dbItem.User; item.UserName = dbUser.UserName; item.FirstName = dbUser.FirstName; item.LastName = dbUser.LastName; item.PhoneNumber = dbUser.PhoneNumber; item.Email = dbUser.Email; return(item); }
public void ShouldNotUpdateFieldsIfItemVersionIsZero(SaveItemCommand sut, DbItem item, FieldList fields, Language language) { // arrange sut.DataStorage.GetFakeItem(item.ID).Returns(item); var updatedItem = ItemHelper.CreateInstance(sut.Database, "updated item", item.ID, ID.NewID, ID.Null, fields, language, new Version(0)); sut.Initialize(updatedItem); // act Action action = () => ReflectionUtil.CallMethod(sut, "DoExecute"); // assert action.ShouldNotThrow(); }
private SiteContext BuildSiteContext(Db db, Db coreDb, ID profileId, ID interestFolder, IEnumerable <string> interests) { var contextId = ID.NewID; var interestItem = new DbItem("InterestsFolder", interestFolder); interests.Select(i => new DbItem(i) { TemplateID = Templates.Interest.ID, Fields = { new DbField("Title", Templates.Interest.Fields.Title) { Value = i } } }) .ToList().ForEach(x => interestItem.Add(x)); db.Add(new DbItem("siteroot") { TemplateID = Templates.ProfileSettigs.ID, Fields = { new DbField("UserProfile", Templates.ProfileSettigs.Fields.UserProfile) { Value = profileId.ToString() }, new DbField("InterestsFolder", Templates.ProfileSettigs.Fields.InterestsFolder) { Value = interestFolder.ToString() } }, Children = { interestItem } }); coreDb.Add(new DbItem("UserProfile", profileId)); var fakeSite = new FakeSiteContext(new StringDictionary { { "rootPath", "/sitecore/content/siteroot" }, { "database", "master" } }) as SiteContext; Context.Item = db.GetItem(interestFolder); return(fakeSite); }
public void FixedSizeItemsPage() { int pageSize = 32768; var dummyPageManager = new FileSystemPageManager(pageSize); var p = new Page(dummyPageManager, 0, new byte[pageSize]); var header = new FixedSizeItemsPageHeader(); var r = new Random(); foreach (var sizeRange in EnumHelper.FixedSizeItemsSizeRanges()) { header.SizeRange = sizeRange; PageFormatter.InitPage(p, header); var item = new DbItem(new byte[DbItem.GetMaxSize(header.SizeRange)]); r.NextBytes(item.RawData); // fill the page with the items short count = 0; bool spaceRemains = true; while (PageFormatter.HasFreeSpaceForFixedSizeItem(p)) { Assert.IsTrue(spaceRemains); PageFormatter.AddFixedSizeItem(p, item, out spaceRemains); count++; Assert.AreEqual(count, PageFormatter.ReadFixedSizeItemsCount(p)); } Assert.IsFalse(spaceRemains); // check if fetched objects are equal to originals for (short j = 0; j < PageFormatter.ReadFixedSizeItemsCount(p); j++) { DbItem readItem = PageFormatter.ReadFixedSizeItem(p, j); Assert.IsTrue(AreEqualByteArrays(item.RawData, readItem.RawData)); } // delete all added items short itemindex = 0; while (PageFormatter.ReadFixedSizeItemsCount(p) > 0) { PageFormatter.DeleteFixedSizeItem(p, itemindex); count--; itemindex++; Assert.AreEqual(count, PageFormatter.ReadFixedSizeItemsCount(p)); } } }
public void Versions_ReturnsExpectedVersions(Db db, DbItem item, Guid fieldId) { item.Fields.Add(new DbField(new ID(fieldId)) { { "en", 1, "test value" }, { "en", 2, "test v2" } }); var dbItem = db.CreateItem(item); var itemData = new ItemData(dbItem); dbItem.Versions.Count.Should().Be(itemData.Versions.Count()); itemData.Versions.Any(v => v.Language.Name == "en" && v.VersionNumber == 1).Should().BeTrue(); itemData.Versions.Any(v => v.Language.Name == "en" && v.VersionNumber == 2).Should().BeTrue(); }
public void MoveItemToNewDestinationReturnsTrue( [Greedy] FakeDataProvider sut, ItemDefinition itemDefinition, ItemDefinition destination, DbItem item, DbItem newDestination) { sut.DataStorage.GetFakeItem(itemDefinition.ID).Returns(item); sut.DataStorage.GetFakeItem(destination.ID).Returns(newDestination); sut.MoveItem(itemDefinition, destination, null).Should().BeTrue(); newDestination.Children.Single().Should().BeSameAs(item); item.ParentID.Should().Be(newDestination.ID); }
/// <summary> /// Check whether an item previously marked for adding or updating is being deleted. If so, remove the previous statement /// </summary> /// <param name="item"></param> /// <returns></returns> private bool CheckStatus(DbItem item) { var cnt = true; foreach ( var ite in _sqlItems.ToList().Where(i => i.Id == item.Id) .Where(ite => item.IsAdding && item.IsDeleting || item.IsModifying && item.IsDeleting)) { _sqlItems.Remove(ite); cnt = false; } return(cnt); }
public void ShouldSetTemplateIdToBranchTemplateIdIfParentIsBrancesAndNoTemplateIdSet(string originalTemplateId, string expectedNewTemlateId) { // arrange var branchItem = new DbItem("branch item") { ParentID = ItemIDs.BranchesRoot, TemplateID = ID.Parse(originalTemplateId) }; var args = new AddDbItemArgs(branchItem, this.dataStorage); // act this.processor.Process(args); // assert branchItem.TemplateID.Should().Be(ID.Parse(expectedNewTemlateId)); }
public void ShouldSetItemWorkflow( SetWorkflow sut, DbItem item, DbTemplate template, [Substitute] DataStorage dataStorage, string workflowId) { template.Add(FieldIDs.DefaultWorkflow, workflowId); dataStorage.GetFakeTemplate(item.TemplateID).Returns(template); var args = new AddDbItemArgs(item, dataStorage); sut.Process(args); item.Fields[FieldIDs.Workflow].Value.Should().Be(workflowId); }
public void RegisterShouldReturnViewWithoutModel(Database db, [Content] DbItem item, [Frozen] IAccountRepository repo, [NoAutoProperties] AccountsController controller) { var fakeSite = new FakeSiteContext(new StringDictionary { { "displayMode", "normal" } }) as SiteContext; using (new SiteContextSwitcher(fakeSite)) { var result = controller.Register(); result.Should().BeOfType <ViewResult>().Which.Model.Should().BeNull(); } }
public void Register_InvalidData_ShouldReturnModel(Database db, [Content] DbItem item, RegistrationInfo registrationInfo, [Frozen] IAccountRepository repo, [NoAutoProperties] AccountsController controller) { var fakeSite = new FakeSiteContext(new StringDictionary { { "displayMode", "normal" } }) as SiteContext; using (new SiteContextSwitcher(fakeSite)) { controller.ModelState.AddModelError("Error", "Error"); var result = controller.Register(registrationInfo); result.Should().BeOfType <ViewResult>().Which.Model.Should().Be(registrationInfo); } }
protected virtual void UpdateBasicData(DbItem fakeItem) { var oldName = fakeItem.Name; var newName = this.Item.Name; fakeItem.Name = this.Item.Name; fakeItem.BranchId = this.Item.BranchId; var fullPath = fakeItem.FullPath; if (!string.IsNullOrEmpty(fullPath) && fullPath.Contains(oldName)) { fakeItem.FullPath = fullPath.Substring(0, fullPath.LastIndexOf(oldName, StringComparison.Ordinal)) + newName; } }
private DbItem GetSourceItem(DbItem fakeItem) { if (!fakeItem.Fields.ContainsKey(SourceFieldId)) { return(null); } var sourceUri = fakeItem.Fields[SourceFieldId].Value; if (!ItemUri.IsItemUri(sourceUri)) { return(null); } return(this.GetFakeItem(new ItemUri(sourceUri).ItemID)); }
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(); } }
public void Save_ShouldNotSerializeItem_IfNoMeaningfulChanges(Db db, DbItem item) { var target = Substitute.For <ITargetDataStore>(); using (var provider = CreateTestProvider(db.Database, targetDataStore: target)) { db.Add(item); var dbItem = db.GetItem(item.ID); var changes = new ItemChanges(dbItem); provider.SaveItem(CreateTestDefinition(), changes, CreateTestCallContext(db.Database)); target.DidNotReceive().Save(Arg.Any <IItemData>(), null); } }
public void AddVersionAddsNewVersionAndReturnsNewVersionNumber( [Greedy] FakeDataProvider sut, ItemDefinition itemDefinition, Language language, int version, DbItem item) { sut.DataStorage.GetFakeItem(itemDefinition.ID).Returns(item); var baseVersion = new VersionUri(language, Version.Parse(version)); var expectedVersion = version + 1; var result = sut.AddVersion(itemDefinition, baseVersion, null); result.Should().Be(expectedVersion); item.GetVersionCount(language.Name).Should().Be(expectedVersion); }
// test fixture setup protected FieldWrapperTestClass() { this.SpawnProvider = Substitute.For <ISpawnProvider>(); // Construct test item. this.Db = new Db(); var item = new DbItem("Test", ID.NewID); this.Field = new DbField(FieldName, ID.NewID); item.Fields.Add(this.Field); this.Db.Add(item); // init sitecore context Sitecore.Context.Site = new FakeSiteContext("website"); Sitecore.Context.Item = this.Item; }
public ConquerItem(DbItem _item) { DbItem = _item; UniqueID = _item.UniqueID; StaticID = _item.StaticID; Durability = _item.Durability; Location = _item.Location; Color = _item.Color; Plus = _item.Plus; Bless = _item.Bless; Enchant = _item.Enchant; Gem1 = _item.Gem1; Gem2 = _item.Gem2; Effect = _item.Effect; Locked = _item.Locked; }