public void ShouldAutoDeserializeIncludingBaseTemplates()
        {
            DsDbItem item = new DsDbItem("/sitecore/content/Home/Some item");

            using (Db db = new Db()
            {
                item
            })
            {
                ID templateId     = ID.Parse("{F6A72DBF-558F-40E5-8033-EE4ACF027FE2}");
                ID baseTemplateId = ID.Parse("{C4F448EB-7CA3-4A27-BA5E-99E8B9022803}");

                item.Should().NotBeNull();
                item.TemplateID.ShouldBeEquivalentTo(templateId);

                Item templateItem = db.GetItem(item.TemplateID);

                templateItem.Should().NotBeNull();
                templateItem.Name.ShouldBeEquivalentTo("Some template");
                templateItem[FieldIDs.BaseTemplate].ShouldBeEquivalentTo(baseTemplateId.ToString());

                Item baseTemplateItem = db.GetItem(baseTemplateId);

                baseTemplateItem.Should().NotBeNull();
                baseTemplateItem.Name.ShouldBeEquivalentTo("Some base template");
                baseTemplateItem.ID.ShouldBeEquivalentTo(baseTemplateId);
            }
        }
        public void ShouldSetName()
        {
            DsDbItem item = new DsDbItem("/sitecore/content/home");

            item.Should().NotBeNull();
            item.Name.Should().BeEquivalentTo("Home");
        }
예제 #3
0
    public void ShouldSetItemId()
    {
      var item = new DsDbItem("/sitecore/content/home");

      item.Should().NotBeNull();
      item.ID.ShouldBeEquivalentTo(SerializationId.ContentHomeItem);
    }
예제 #4
0
    public void ShouldSetName()
    {
      var item = new DsDbItem("/sitecore/content/home");

      item.Should().NotBeNull();
      item.Name.Should().BeEquivalentTo("Home");
    }
예제 #5
0
    public void ShouldSetTemplateId()
    {
      var item = new DsDbItem("/sitecore/content/home");

      item.Should().NotBeNull();
      item.TemplateID.ShouldBeEquivalentTo(SerializationId.SampleItemTemplate);
    }
예제 #6
0
        public void ShouldSetTemplateId()
        {
            var item = new DsDbItem("/sitecore/content/home");

            item.Should().NotBeNull();
            item.TemplateID.ShouldBeEquivalentTo(SerializationId.SampleItemTemplate);
        }
예제 #7
0
        public void ShouldSetItemId()
        {
            var item = new DsDbItem("/sitecore/content/home");

            item.Should().NotBeNull();
            item.ID.ShouldBeEquivalentTo(SerializationId.ContentHomeItem);
        }
        public void Process(DsItemLoadingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            DsDbItem dsDbItem = args.DsDbItem as DsDbItem;

            if (dsDbItem == null)
            {
                return;
            }

            // Deserialize and link descendants, if needed
            FileInfo file = args.DsDbItem.File;

            if (dsDbItem.IncludeDescendants && file.Directory != null)
            {
                DirectoryInfo childItemsFolder = new DirectoryInfo(
                    file.Directory.FullName + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file.Name));
                if (childItemsFolder.Exists)
                {
                    foreach (var itemFile in childItemsFolder.GetFiles("*.item", SearchOption.TopDirectoryOnly))
                    {
                        DsDbItem childItem = new DsDbItem(dsDbItem.SerializationFolderName, itemFile, true);
                        dsDbItem.Children.Add(childItem);
                    }
                }
            }
        }
        public void ShouldLookupById()
        {
            ID id = ID.Parse("{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}");

            DsDbItem item = new DsDbItem(id);

            item.Should().NotBeNull();
            item.Name.Should().BeEquivalentTo("Home");
            item.ID.ShouldBeEquivalentTo(id);
        }
예제 #10
0
        public void ShouldLookupById()
        {
            var id = SerializationId.ContentHomeItem;

            var item = new DsDbItem(id);

            item.Should().NotBeNull();
            item.Name.Should().BeEquivalentTo("Home");
            item.ID.ShouldBeEquivalentTo(id);
        }
        public void ShouldDetermineFolderFromContextDatabase()
        {
            using (new DatabaseSwitcher(Database.GetDatabase("core")))
            {
                DsDbItem item = new DsDbItem("/sitecore/content/Applications");

                item.Should().NotBeNull();
                item.Name.ShouldBeEquivalentTo("Applications");
            }
        }
예제 #12
0
    public void ShouldDeserializeNullBaseTemplateItem()
    {
      var item = new DsDbItem("/sitecore/content/New Item Without BaseTemplates");

      using (var db = new Db { item })
      {
        var linkedTemplate = db.GetItem(item.TemplateID);
        linkedTemplate.Should().NotBeNull();
        linkedTemplate.Template.Name.ShouldBeEquivalentTo("Template");
      }
    }
예제 #13
0
        public void ShouldDeserializeNullBaseTemplateItem()
        {
            var item = new DsDbItem("/sitecore/content/New Item Without BaseTemplates");

            using (var db = new Db {
                item
            })
            {
                var linkedTemplate = db.GetItem(item.TemplateID);
                linkedTemplate.Should().NotBeNull();
                linkedTemplate.Template.Name.ShouldBeEquivalentTo("Template");
            }
        }
예제 #14
0
        public void ShouldNotAutoDeserializeLinkedTemplate()
        {
            var item = new DsDbItem("/sitecore/content/home", false, false);

            using (var db = new Db {
                item
            })
            {
                item.Should().NotBeNull();

                var templateItem = db.GetItem(item.TemplateID);
                templateItem.Name.Should().NotBe("Sample Item");
            }
        }
예제 #15
0
    public void ShouldBeAppliedToDeserializedItem()
    {
      var template = new DsDbTemplate("/sitecore/templates/Sample/Sample Item");
      var item = new DsDbItem("/sitecore/content/Home");
      using (new Db { template, item })
      {
        item.TemplateID.ShouldBeEquivalentTo(template.ID);

        var titleFieldId = ID.Parse("{75577384-3C97-45DA-A847-81B00500E250}");

        item.Fields[titleFieldId].Value.ShouldBeEquivalentTo("Sitecore");
        template.Fields[titleFieldId].Should().NotBeNull();
      }
    }
        public void Process(DsItemLoadingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            DsDbItem dsDbItem = args.DsDbItem as DsDbItem;

            if (dsDbItem == null ||
                !dsDbItem.DeserializeLinkedTemplate ||
                args.DataStorage.GetFakeItem(dsDbItem.TemplateID) != null)
            {
                return;
            }

            DeserializeTemplate(args.DataStorage, dsDbItem.TemplateID, dsDbItem.SerializationFolderName);
        }
예제 #17
0
    public void ShouldDeserializeDescendants()
    {
      var item = new DsDbItem("/sitecore/content/home", true);
      using (new Db { item })
      {
        item.Should().NotBeNull();

        var child = item.Children.FirstOrDefault(c => c.Name == "Child Item");
        child.Should().NotBeNull();
        child.Name.Should().BeEquivalentTo("Child Item");

        var grandChild = child.Children.FirstOrDefault(c => c.Name == "Grandchild Item");
        grandChild.Should().NotBeNull();
        grandChild.Name.Should().BeEquivalentTo("Grandchild Item");
      }
    }
예제 #18
0
        public void ShouldBeAppliedToDeserializedItem()
        {
            var template = new DsDbTemplate("/sitecore/templates/Sample/Sample Item");
            var item     = new DsDbItem("/sitecore/content/Home");

            using (new Db {
                template, item
            })
            {
                item.TemplateID.ShouldBeEquivalentTo(template.ID);

                var titleFieldId = ID.Parse("{75577384-3C97-45DA-A847-81B00500E250}");

                item.Fields[titleFieldId].Value.ShouldBeEquivalentTo("Sitecore");
                template.Fields[titleFieldId].Should().NotBeNull();
            }
        }
예제 #19
0
        public void ShouldAutoDeserializeLinkedTemplate()
        {
            var item = new DsDbItem("/sitecore/content/home");

            using (var db = new Db {
                item
            })
            {
                var templateId = ID.Parse("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}");

                item.Should().NotBeNull();
                item.TemplateID.ShouldBeEquivalentTo(templateId);

                var templateItem = db.GetItem(item.TemplateID);

                templateItem.Should().NotBeNull();
                templateItem.Name.ShouldBeEquivalentTo("Sample Item");
            }
        }
예제 #20
0
        public void ShouldAutoDeserializeLinkedTemplate()
        {
            var item = new DsDbItem("/sitecore/content/home");

            using (var db = new Db {
                item
            })
            {
                var templateId = SerializationId.SampleItemTemplate;

                item.Should().NotBeNull();
                item.TemplateID.ShouldBeEquivalentTo(templateId);

                var templateItem = db.GetItem(item.TemplateID);

                templateItem.Should().NotBeNull();
                templateItem.Name.ShouldBeEquivalentTo("Sample Item");
            }
        }
        public void Process(DsItemLoadingArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var dsDbItem = args.DsDbItem as DsDbItem;

            if (dsDbItem == null)
            {
                return;
            }

            // Deserialize and link descendants, if needed
            var file = args.DsDbItem.File;

            if (!dsDbItem.IncludeDescendants || file.Directory == null)
            {
                return;
            }

            var childItemsFolder = new DirectoryInfo(file.Directory.FullName + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file.Name));

            if (!childItemsFolder.Exists)
            {
                return;
            }

            foreach (var itemFile in childItemsFolder.GetFiles("*.item", SearchOption.TopDirectoryOnly))
            {
                DbItem childItem;
                var    syncItem = itemFile.Deserialize();

                if (syncItem.TemplateID == TemplateIDs.Template.ToString())
                {
                    childItem = new DsDbTemplate(dsDbItem.SerializationFolderName, syncItem, itemFile);
                }
                else
                {
                    childItem = new DsDbItem(dsDbItem.SerializationFolderName, syncItem, itemFile, true);
                }

                dsDbItem.Children.Add(childItem);
            }
        }
예제 #22
0
        public void ShouldDeserializeDescendants()
        {
            var item = new DsDbItem("/sitecore/content/home", true);

            using (new Db {
                item
            })
            {
                item.Should().NotBeNull();

                var child = item.Children.FirstOrDefault(c => c.Name == "Child Item");
                child.Should().NotBeNull();
                child.Name.Should().BeEquivalentTo("Child Item");

                var grandChild = child.Children.FirstOrDefault(c => c.Name == "Grandchild Item");
                grandChild.Should().NotBeNull();
                grandChild.Name.Should().BeEquivalentTo("Grandchild Item");
            }
        }
    public void Process(DsItemLoadingArgs args)
    {
      Assert.ArgumentNotNull(args, "args");

      var dsDbItem = args.DsDbItem as DsDbItem;

      if (dsDbItem == null)
      {
        return;
      }

      // Deserialize and link descendants, if needed
      var file = args.DsDbItem.File;
      if (!dsDbItem.IncludeDescendants || file.Directory == null)
      {
        return;
      }

      var childItemsFolder = new DirectoryInfo(file.Directory.FullName + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file.Name));
      if (!childItemsFolder.Exists)
      {
        return;
      }

      foreach (var itemFile in childItemsFolder.GetFiles("*.item", SearchOption.TopDirectoryOnly))
      {
        DbItem childItem;
        var syncItem = itemFile.Deserialize();

        if (syncItem.TemplateID == TemplateIDs.Template.ToString())
        {
          childItem = new DsDbTemplate(dsDbItem.SerializationFolderName, syncItem, itemFile);
        }
        else
        {
          childItem = new DsDbItem(dsDbItem.SerializationFolderName, syncItem, itemFile, true);
        }

        dsDbItem.Children.Add(childItem);
      }
    }
예제 #24
0
    public void ShouldDeserializeMultilingualItem()
    {
      var item = new DsDbItem("/sitecore/content/home");

      using (new Db { item })
      {
        item.Should().NotBeNull();

        var titleFieldId = ID.Parse("{75577384-3C97-45DA-A847-81B00500E250}");
        var sharedFieldId = ID.Parse("{8F0BDC2B-1A78-4C29-BF83-C1C318186AA6}");

        item.Fields[titleFieldId].Value.Should().BeEquivalentTo("Sitecore");
        item.Fields[sharedFieldId].Value.Should().BeEquivalentTo("This value should be the same in all languages");

        using (new LanguageSwitcher("de-DE"))
        {
          item.Fields[titleFieldId].Value.Should().BeEquivalentTo("Sitekern");
          item.Fields[sharedFieldId].Value.Should().BeEquivalentTo("This value should be the same in all languages");
        }
      }
    }
예제 #25
0
    public void ShouldDetermineFolderFromContextDatabase()
    {
      using (new DatabaseSwitcher(Database.GetDatabase("core")))
      {
        var item = new DsDbItem("/sitecore/content/Applications");

        item.Should().NotBeNull();
        item.Name.ShouldBeEquivalentTo("Applications");
      }
    }
 public DeserializeSystemItem()
 {
   var item = new DsDbItem(SerializationId.MySystemItem, true);
   this.Db.Add(item);
 }
예제 #27
0
        public void ShouldDeserializeShortenedPath()
        {
            var item = new DsDbItem("/sitecore/content/this/path must be very deep/so that it will be shortened/on the filesystem/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/still deeper");

            item.Should().NotBeNull();
        }
예제 #28
0
    public void ShouldLookupByIdInShortenedPath()
    {
      var id = ID.Parse("{9897418C-9D6A-4AC9-B08A-15064C9582A9}");

      var item = new DsDbItem(id);

      item.Should().NotBeNull();
      item.Name.Should().BeEquivalentTo("still deeper");
      item.ID.ShouldBeEquivalentTo(id);
    }
        public void ShouldDeserializeShortenedPathOneDirectoryHigher()
        {
            DsDbItem item = new DsDbItem("/sitecore/content/this/path must be very deep/so that it will be shortened/on the filesystem/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");

            item.Should().NotBeNull();
        }
예제 #30
0
    public void ShouldDeserializeShortenedPathOneDirectoryHigher()
    {
      var item = new DsDbItem("/sitecore/content/this/path must be very deep/so that it will be shortened/on the filesystem/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");

      item.Should().NotBeNull();
    }
예제 #31
0
    public void ShouldAutoDeserializeIncludingBaseTemplates()
    {
      var item = new DsDbItem("/sitecore/content/Home/Some item");
      using (var db = new Db { item })
      {
        var templateId = ID.Parse("{F6A72DBF-558F-40E5-8033-EE4ACF027FE2}");
        var baseTemplateId = ID.Parse("{C4F448EB-7CA3-4A27-BA5E-99E8B9022803}");

        item.Should().NotBeNull();
        item.TemplateID.ShouldBeEquivalentTo(templateId);

        var templateItem = db.GetItem(item.TemplateID);

        templateItem.Should().NotBeNull();
        templateItem.Name.ShouldBeEquivalentTo("Some template");
        templateItem[FieldIDs.BaseTemplate].ShouldBeEquivalentTo(baseTemplateId.ToString());

        var baseTemplateItem = db.GetItem(baseTemplateId);

        baseTemplateItem.Should().NotBeNull();
        baseTemplateItem.Name.ShouldBeEquivalentTo("Some base template");
        baseTemplateItem.ID.ShouldBeEquivalentTo(baseTemplateId);
      }
    }
예제 #32
0
    public void ShouldNotAutoDeserializeLinkedTemplate()
    {
      var item = new DsDbItem("/sitecore/content/home", false, false);
      using (var db = new Db { item })
      {
        item.Should().NotBeNull();

        var templateItem = db.GetItem(item.TemplateID);
        templateItem.Name.Should().NotBe("Sample Item");
      }
    }
예제 #33
0
    public void ShouldAutoDeserializeLinkedTemplate()
    {
      var item = new DsDbItem("/sitecore/content/home");
      using (var db = new Db { item })
      {
        var templateId = SerializationId.SampleItemTemplate;

        item.Should().NotBeNull();
        item.TemplateID.ShouldBeEquivalentTo(templateId);

        var templateItem = db.GetItem(item.TemplateID);

        templateItem.Should().NotBeNull();
        templateItem.Name.ShouldBeEquivalentTo("Sample Item");
      }
    }
예제 #34
0
    public void ShouldLookupById()
    {
      var id = SerializationId.ContentHomeItem;

      var item = new DsDbItem(id);

      item.Should().NotBeNull();
      item.Name.Should().BeEquivalentTo("Home");
      item.ID.ShouldBeEquivalentTo(id);
    }
예제 #35
0
    public void ShouldLoadFromSpecifiedFolder()
    {
      var item = new DsDbItem("/sitecore/content/Item only available in custom serialization folder", "custom");

      item.Should().NotBeNull();
    }
예제 #36
0
        public DeserializeSystemItem()
        {
            var item = new DsDbItem(SerializationId.MySystemItem, true);

            this.Db.Add(item);
        }