public void should_throw_if_args_is_null()
        {
            // Arrange
            var processor = new IsIntegrationInstance(new SitecoreEventManager(), this.azureEnvironment);

            // Act
            Action action = () => processor.Process(null);

            // Assert
            action.ShouldThrow <ArgumentNullException>().WithMessage("Value cannot be null.\r\nParameter name: args");
        }
        public void should_queue_event_if_IsEven_is_false()
        {
            // Arrange
            var eventManager = Substitute.For <SitecoreEventManager>();
            var processor    = new IsIntegrationInstance(eventManager, this.azureEnvironment);
            var args         = new SynchronizeTreeArgs
            {
                Context = this.synchContext,
                Options = ProcessIntegrationItemsOptions.DefaultOptions
            };

            args.Options.IsEvent = false;

            // Act
            processor.Process(args);

            // Assert
            eventManager.Received().QueueEvent(Arg.Is <ProcessTreeRemoteEvent>(x => x.DatabaseName == args.Context.Database.Name && x.Id == args.Context.ParentID && x.EventName == "spif:processTree"));
        }
        public void should_not_queue_event_if_IsEven_is_true()
        {
            // Arrange
            var eventManager = Substitute.For <SitecoreEventManager>();
            var processor    = new IsIntegrationInstance(eventManager, this.azureEnvironment);
            var args         = new SynchronizeTreeArgs
            {
                Context = this.synchContext,
                Options = ProcessIntegrationItemsOptions.DefaultOptions
            };

            args.Options.IsEvent = true;

            // Act
            processor.Process(args);

            // Assert
            eventManager.DidNotReceiveWithAnyArgs().QueueEvent(Arg.Any <ProcessTreeRemoteEvent>());
        }
        public void should_abort_pipeline_if_not_integration_instance_in_azure()
        {
            // Arrange
            var processor = new IsIntegrationInstance(Substitute.For <SitecoreEventManager>(), this.azureEnvironment);
            var args      = new SynchronizeTreeArgs
            {
                Context = this.synchContext,
                Options = ProcessIntegrationItemsOptions.DefaultOptions
            };

            this.azureEnvironment.IsAzure.Returns(true);
            this.azureEnvironment.IsIntegrationInstance.Returns(false);

            // Act
            using (new SettingsSwitcher("Sharepoint.IntegrationInstance", Settings.InstanceName))
            {
                processor.Process(args);
            }

            // Assert
            args.Aborted.Should().BeTrue();
        }