public void StartAsyncTest() { PipelineCreationOptions options = PipelineCreationOptions.DestinationIsFile; var Pipe = Pipeline.CreatePipeline(context, options); Task t = Pipe.StartAsync(); Task.Delay(1000).Wait(); Assert.IsTrue(File.Exists(context.DestinationFilePath)); t.Wait(); string[] fileContent = File.ReadAllLines(context.DestinationFilePath); Assert.IsTrue(fileContent.Count() == 10001); //10 000 records PLUS the headerline Assert.AreEqual(expected: "OddNumbers|~|EvenNumbers", actual: fileContent[0]); int SumEven = 0; int SumOdd = 0; int ExpectedEven = 0; int ExpectedOdd = 0; for (int i = 1; i < 10001; i++) //start at one! { SumEven += int.Parse(fileContent[i].Split(new[] { "|~|" }, StringSplitOptions.None).Last()); SumOdd += int.Parse(fileContent[i].Split(new[] { "|~|" }, StringSplitOptions.None).First()); } for (int i = 0; i < 20 * 1000; i += 2) { ExpectedOdd += i + 1; ExpectedEven += i; } Assert.AreEqual(expected: ExpectedEven, actual: SumEven); Assert.AreEqual(expected: ExpectedOdd, actual: SumOdd); }
public void TogglePauseTest() { PipelineCreationOptions options = PipelineCreationOptions.DestinationIsFile; var Pipe = Pipeline.CreatePipeline(context, options); Assert.AreEqual(expected: typeof(SqlTableToFlatFilePipeline), actual: Pipe.GetType()); Assert.ThrowsException <NotImplementedException>( () => Pipe.TogglePause()); Assert.ThrowsException <NotImplementedException>( () => Pipe.IsPaused); }
public void SqlTableToFlatFilePipelineTest() { PipelineCreationOptions options = PipelineCreationOptions.DestinationIsFile; var Pipe = Pipeline.CreatePipeline(context, options); Assert.AreEqual(expected: typeof(SqlTableToFlatFilePipeline), actual: Pipe.GetType()); PipelineContext falseContext = new PipelineContext() { SourceTableName = " hufdspafhpawefawepjoifwaepjoifawefpoijaefjpoi", DestinationFilePath = "huyerfwaeafsahuifdsahuifd" }; //check that exception is thrown when nonsense names are supplied in the context Assert.ThrowsException <ArgumentException>( () => Pipe = Pipeline.CreatePipeline(falseContext, options)); }
public static IPipeline CreatePipeline(PipelineContext context, PipelineCreationOptions options) { switch (options) { case PipelineCreationOptions.None: return(new ScalingParallelPipeline(context)); case PipelineCreationOptions.PreferSequentialPipeline: return(CreatePipeline(context)); case PipelineCreationOptions.InjectTransformationTask: throw new NotImplementedException(); case PipelineCreationOptions.UseBcdbPipeline: throw new NotImplementedException(); case PipelineCreationOptions.DestinationIsFile: return(new SqlTableToFlatFilePipeline(context)); default: throw new ArgumentException("invalid value of parameter", "options"); } }