public void ShouldNotStartSyncForeRegularItem()
        {
            // Arrange
            Item item = new ItemMock();

            using (new ItemIsContentItem(item))
            {
                var args = new GetChildrenArgs(this.itemProvider, item, SecurityCheck.Disable, ChildListOptions.None);

                // Act
                this.processor.Process(args);

                // Assert
                item.ID.WasSyncStarted().Should().BeFalse();
            }
        }
        public void ShouldNotStartSyncIfIntegrationDisabled()
        {
            // Arrange
            Item item = new ItemMock();

            IntegrationCache.RemoveIntegrationConfigData(item.ID);
            var args = new GetChildrenArgs(this.itemProvider, item, SecurityCheck.Disable, ChildListOptions.None);

            // Act
            using (new IntegrationDisabler())
            {
                this.processor.Process(args);
            }

            // Assert
            item.ID.WasSyncStarted().Should().BeFalse();
        }
        public void ShouldStartSyncForFolder()
        {
            Item item = Substitute.For <Database>().CreateConfigurationFolder();

            using (new ItemIsContentItem(item))
            {
                // Arrange
                IntegrationCache.RemoveIntegrationConfigData(item.ID);
                var args = new GetChildrenArgs(this.itemProvider, item, SecurityCheck.Disable, ChildListOptions.None);

                // Act
                this.processor.Process(args);

                // Assert
                item.ID.WasSyncStarted().Should().BeTrue();
            }
        }
        public void ShouldNotGetChildrenIfHandled()
        {
            Item item = Substitute.For <Database>().CreateConfigurationFolder();

            using (new ItemIsContentItem(item))
            {
                // Arrange
                var args = new GetChildrenArgs(this.itemProvider, item, SecurityCheck.Disable, ChildListOptions.None)
                {
                    Handled = true
                };

                // Act
                this.processor.Process(args);

                // Assert
                this.itemProvider.DidNotReceiveWithAnyArgs().GetChildren(default(Item), default(SecurityCheck));
            }
        }
Beispiel #5
0
        /// <summary>The process.</summary>
        /// <param name="args">The args.</param>
        public virtual void Process([NotNull] GetChildrenArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (!IntegrationDisabler.CurrentValue)
            {
                if (SharepointProvider.IsActiveIntegrationConfigItem(args.Item) || SharepointProvider.IsActiveIntegrationFolder(args.Item))
                {
                    SharepointProvider.ProcessTree(args.Item, ProcessIntegrationItemsOptions.DefaultAsyncOptions);
                }
            }

            if (!args.Handled)
            {
                using (new IntegrationDisabler())
                {
                    args.Result  = args.FallbackProvider.GetChildren(args.Item, args.SecurityCheck);
                    args.Handled = true;
                }
            }
        }
        public void ShouldGetChildren()
        {
            Item item = Substitute.For <Database>().CreateConfigurationFolder();

            using (new ItemIsContentItem(item))
            {
                // Arrange
                var args      = new GetChildrenArgs(this.itemProvider, item, SecurityCheck.Disable, ChildListOptions.None);
                var childList = new ChildList(item, new ItemList());
                this.itemProvider.GetChildren(item, SecurityCheck.Disable)
                .Returns(childList)
                .AndDoes(obj => IntegrationDisabler.CurrentValue.Should().BeTrue());

                // Act
                this.processor.Process(args);

                // Assert
                args.Handled.Should().BeTrue();
                args.Result.As <object>().Should().BeSameAs(childList);
                IntegrationDisabler.CurrentValue.Should().BeFalse();
            }
        }