public void NoIterableDataSettingsPluginAddedToPipelineContextWhenNoEndpointSettingsPluginIsSetOnThePipelineStep()
        {
            var pipelineStep = new PipelineStep {
                Enabled = true
            };
            var pipelineContext = new PipelineContext(new PipelineBatchContext());
            var logger          = Substitute.For <ILogger>();
            var processor       = new ReadTextFileStepProcessor();

            processor.StartProcessing(pipelineStep, pipelineContext, logger);
            Assert.Null(pipelineContext.GetPlugin <IterableDataSettings>());
        }
        public void IterableDataSettingsPluginAddedToPipelineContext()
        {
            var builder = new StringBuilder();

            builder.AppendLine("a-b-c");
            builder.AppendLine("1-2-3");
            var fileName = Path.GetTempFileName();

            File.WriteAllText(fileName, builder.ToString());
            var textFileSettings = new TextFileSettings
            {
                Path = fileName,
                ColumnHeadersInFirstLine = false,
                ColumnSeparator          = "-"
            };
            var endpointFrom = new Endpoint();

            endpointFrom.AddPlugin(textFileSettings);
            var pipelineStep = new PipelineStep {
                Enabled = true
            };

            pipelineStep.AddPlugin(new EndpointSettings {
                EndpointFrom = endpointFrom
            });
            var pipelineContext = new PipelineContext(new PipelineBatchContext());
            var logger          = Substitute.For <ILogger>();
            var processor       = new ReadTextFileStepProcessor();

            processor.StartProcessing(pipelineStep, pipelineContext, logger);
            var dataSettings = pipelineContext.GetPlugin <IterableDataSettings>();

            Assert.NotNull(dataSettings);
            Assert.NotNull(dataSettings.Data);
            var count = 0;

            foreach (var data in dataSettings.Data)
            {
                Assert.NotNull(data);
                Assert.IsType <string[]>(data);
                var dataAsArray = data as string[];
                Assert.NotNull(dataAsArray);
                Assert.Equal(3, dataAsArray.Length);
                count++;
            }
            Assert.Equal(2, count);
            File.Delete(fileName);
        }
        public void NoIterableDataSettingsPluginAddedToPipelineContextWhenNoPathIsSetOnTheTextFileSettingsPluginSetOnTheEndpoint()
        {
            var textFileSettings = new TextFileSettings();
            var endpointFrom     = new Endpoint();

            endpointFrom.AddPlugin(textFileSettings);
            var pipelineStep = new PipelineStep {
                Enabled = true
            };

            pipelineStep.AddPlugin(new EndpointSettings {
                EndpointFrom = endpointFrom
            });
            var pipelineContext = new PipelineContext(new PipelineBatchContext());
            var logger          = Substitute.For <ILogger>();
            var processor       = new ReadTextFileStepProcessor();

            processor.StartProcessing(pipelineStep, pipelineContext, logger);
            Assert.Null(pipelineContext.GetPlugin <IterableDataSettings>());
        }