public virtual void Process(AddDbItemArgs args)
        {
            var item        = args.DbItem;
            var dataStorage = args.DataStorage;

            dataStorage.FakeItems.Add(item.ID, item);
        }
Exemple #2
0
        public void ProcessSetsSameCreateAndUpdateInfoForAllLanguages(
            string statisticField,
            SetStatistics sut,
            [Frozen] DbItem item,
            AddDbItemArgs args,
            ID id1,
            ID id2,
            string value1,
            string value2)
        {
            var statisticFieldId = ID.Parse(statisticField);
            var fieldEn          = new DbField(id1)
            {
                { "en", value1 }
            };
            var fieldDa = new DbField(id2)
            {
                { "da", value2 }
            };

            item.Fields.Add(fieldEn);
            item.Fields.Add(fieldDa);

            sut.Process(args);
            var valueEn = item.Fields[statisticFieldId].GetValue("en", 0);
            var valueDa = item.Fields[statisticFieldId].GetValue("da", 0);

            valueEn.Should().Be(valueDa);
        }
Exemple #3
0
        public void ProcessSetsUniqueRevisionsForAllLanguages(
            SetStatistics sut,
            [Frozen] DbItem item,
            AddDbItemArgs args,
            ID id1,
            ID id2,
            string value1,
            string value2)
        {
            var fieldEn = new DbField(id1)
            {
                { "en", value1 }
            };
            var fieldDa = new DbField(id2)
            {
                { "da", value2 }
            };

            item.Fields.Add(fieldEn);
            item.Fields.Add(fieldDa);

            sut.Process(args);
            var revisionEn = item.Fields[FieldIDs.Revision].GetValue("en", 0);
            var revisionDa = item.Fields[FieldIDs.Revision].GetValue("da", 0);

            revisionEn.Should().NotBeNullOrEmpty();
            revisionDa.Should().NotBeNullOrEmpty();
            revisionEn.Should().NotBe(revisionDa);
        }
        public virtual void Process(AddDbItemArgs args)
        {
            var item        = args.DbItem;
            var dataStorage = args.DataStorage;

            if (!dataStorage.GetFakeItem(item.ParentID).Children.Contains(item))
            {
                dataStorage.GetFakeItem(item.ParentID).Children.Add(item);
            }
        }
Exemple #5
0
        public void ShouldAddFirstVersion()
        {
            // arrange
            var processor = new AddVersion();
            var args      = new AddDbItemArgs(new DbItem("home"), new DataStorage(Database.GetDatabase("master")));

            // act
            processor.Process(args);

            // assert
            args.DbItem.GetVersionCount("en").Should().Be(1);
        }
Exemple #6
0
        public void ShouldAddVersionInTheGivenLanguage()
        {
            // arrange
            var processor = new AddVersion();
            var args      = new AddDbItemArgs(new DbItem("home"), new DataStorage(Database.GetDatabase("master")), Language.Parse("fr-FR"));

            // act
            processor.Process(args);

            // assert
            args.DbItem.GetVersionCount("fr-FR").Should().Be(1);
        }
        public virtual void Process(AddDbItemArgs args)
        {
            var item        = args.DbItem;
            var dataStorage = args.DataStorage;

            foreach (var child in item.Children)
            {
                child.ParentID = item.ID;
                child.FullPath = item.FullPath + "/" + child.Name;
                dataStorage.AddFakeItem(child);
            }
        }
        public void ShouldAddFirstVersion()
        {
            // arrange
            var processor = new AddVersion();
            var args      = new AddDbItemArgs(new DbItem("home"), new DataStorage());

            // act
            processor.Process(args);

            // assert
            args.DbItem.VersionsCount["en"].Should().Be(1);
        }
Exemple #9
0
        public void ProcessSetsStatisticsForItemWithoutFieldsInDefaultLanguage(
            string statisticField,
            SetStatistics sut,
            [Frozen] DbItem item,
            AddDbItemArgs args)
        {
            var statisticFieldId = ID.Parse(statisticField);

            sut.Process(args);
            var value = item.Fields[statisticFieldId].GetValue("en", 0);

            value.Should().NotBeNullOrEmpty();
        }
Exemple #10
0
        public void ShouldNotSetWorkflowIfNoDefaultWorkflowOnTemplate(
            SetWorkflow sut,
            DbItem item,
            DbTemplate template,
            [Substitute] DataStorage dataStorage)
        {
            dataStorage.GetFakeTemplate(item.TemplateID).Returns(template);
            var args = new AddDbItemArgs(item, dataStorage);

            sut.Process(args);

            item.Fields.ContainsKey(FieldIDs.Workflow).Should().BeFalse();
        }
    public virtual void Process(AddDbItemArgs args)
    {
      var item = args.DbItem;
      var dataStorage = args.DataStorage;

      if (item.ParentID == args.DefaultItemRoot)
      {
        item.FullPath = Constants.ContentPath + "/" + item.Name;
        return;
      }

      var parent = dataStorage.GetFakeItem(item.ParentID);
      item.FullPath = parent.FullPath + "/" + item.Name;
    }
        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 virtual void Process(AddDbItemArgs args)
        {
            var item        = args.DbItem;
            var dataStorage = args.DataStorage;

            if (item.ParentID == args.DefaultItemRoot)
            {
                item.FullPath = Constants.ContentPath + "/" + item.Name;
                return;
            }

            var parent = dataStorage.GetFakeItem(item.ParentID);

            item.FullPath = parent.FullPath + "/" + item.Name;
        }
Exemple #14
0
        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);
        }
Exemple #15
0
        public void ProcessSetsValidRevision(
            SetStatistics sut,
            [Frozen] DbItem item,
            AddDbItemArgs args,
            ID id,
            string value)
        {
            var field = new DbField(id)
            {
                { "en", value }
            };

            item.Fields.Add(field);

            sut.Process(args);
            var actual = item.Fields[FieldIDs.Revision].GetValue("en", 0);

            Assert.True(ID.IsID(actual));
        }
Exemple #16
0
 public void ShouldNotSetWorkflowIfNoTemplateFound(SetWorkflow sut, AddDbItemArgs args, DbItem item)
 {
     sut.Process(args);
     item.Fields.ContainsKey(FieldIDs.Workflow).Should().BeFalse();
 }