public void shouldBuildSimplePipeline() { var testee = new PipelineManager(); var results = testee.BuildPipeline(this.scheme, new TestSubject()); for (var index = 0; index < results.Count; index++) { Assert.IsTrue(results[index].Outcome == StepBuildResults.Completed, results.PrintContentsToString('\n')); } }
public void shouldNotCacheUnusedMethodsAtRebuildUsingBuild() { var testee = new PipelineManager(this.scheme); testee.BuildPipeline(new TestSubject()); var nameOfShort = typeof(short).AssemblyQualifiedName; var nameOfInt = typeof(int).AssemblyQualifiedName; var nameOfTestSubj = typeof(TestSubject).AssemblyQualifiedName; var secondConfig = "{" + nameOfTestSubj + "; Add3; " + nameOfShort + "; " + nameOfShort + "; (0,2)}\n" + "{" + nameOfTestSubj + "; Square; " + nameOfShort + "; " + nameOfInt + "; (0,0)}\n" + "{" + nameOfTestSubj + "; Squareroot; " + nameOfInt + "; " + nameOfShort + "; (0,1)}\n" + "{" + nameOfTestSubj + "; Subtract3; " + nameOfShort + "; " + nameOfShort + "; (0,5)}\n"; var secondScheme = PipelineScheme.Parse(secondConfig); testee.BuildPipeline(secondScheme, new TestSubject()); var cacheCollection = testee.GetType().GetField("unusedSteps", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var actualCollection = (Dictionary<StepMetadata, StepWrapper>)cacheCollection.GetValue(testee); Assert.IsTrue(actualCollection.IsNull() || actualCollection.Count == 0); }
public void shouldProcessDataChunk() { var expected = new short[] { 2, 3, 4, 5, 10 }; var testee = new PipelineManager(this.scheme); testee.BuildPipeline(new TestSubject()); try { testee.ExecuteOnCollection(expected); } catch (InvalidOperationException) { Assert.Fail("Methods missing from pipeline:\n" + testee.GetMetadataForMissingSteps().PrintContentsToString('\n')); } var actual = testee.GetResults<short>(); Assert.IsTrue(expected.SequenceEqual(actual)); }
public void shouldRebuildPipeline() { // Setup test object and states. (states are represented by the scheme objects) var rebuildingTestee = new PipelineManager(this.scheme); var nameOfShort = typeof(short).AssemblyQualifiedName; var nameOfInt = typeof(int).AssemblyQualifiedName; var nameOfTestSubj = typeof(TestSubject).AssemblyQualifiedName; var secondConfig = "{" + nameOfTestSubj + "; Add3; " + nameOfShort + "; " + nameOfShort + "; (0,2)}\n" + "{" + nameOfTestSubj + "; Square; " + nameOfShort + "; " + nameOfInt + "; (0,0)}\n" + "{" + nameOfTestSubj + "; Squareroot; " + nameOfInt + "; " + nameOfShort + "; (0,1)}\n" + "{" + nameOfTestSubj + "; Subtract3; " + nameOfShort + "; " + nameOfShort + "; (0,5)}\n"; var secondScheme = PipelineScheme.Parse(secondConfig); var buildResults = rebuildingTestee.BuildPipeline(new TestSubject()); foreach (var entry in buildResults) { Assert.IsTrue(entry.Outcome == StepBuildResults.Completed, "First build did not succeed\n" + buildResults.PrintContentsToString('\n')); } buildResults = rebuildingTestee.RebuildPipeline(secondScheme, new TestSubject()); foreach (var entry in buildResults) { Assert.IsTrue(entry.Outcome == StepBuildResults.Completed, "Second build did not succeed\n" + buildResults.PrintContentsToString('\n')); } }
public void shouldProcessDataPiece() { var expected = (short)2; var testee = new PipelineManager(this.scheme); testee.BuildPipeline(new TestSubject()); try { testee.ExecuteOnData(expected); } catch (InvalidOperationException) { Assert.Fail("Methods missing from pipeline:\n" + testee.GetMetadataForMissingSteps().PrintContentsToString('\n')); } var actual = testee.GetResults<short>(); Assert.IsTrue(expected.Equals(actual[0])); }