public void Run_ReturnValue_WithInitialValues_CallsInternalRunner() { var initialValue = new object(); var runResult = new object(); const string pipelineName = "Pipeline"; var pipeline = new Mock <IPipeline>(); var pipelineRepository = new Mock <IPipelineRepository>(); pipelineRepository.Setup(r => r.Get(pipelineName)).Returns(pipeline.Object); var pipelineContext = new Mock <IPipelineContext>(); var internalPipelineRunner = new Mock <IInternalPipelineRunner>(); internalPipelineRunner .Setup(r => r.Run(pipeline.Object, pipelineContext.Object)) .Returns(runResult) .Callback(() => pipelineContext.Verify(c => c.SetValue(initialValue))); var runner = new PipelineRunner(pipelineName, pipelineRepository.Object, internalPipelineRunner.Object, pipelineContext.Object); var result = runner.Run <object>(initialValue); internalPipelineRunner.Verify(r => r.Run(pipeline.Object, pipelineContext.Object)); result.Should().Be(runResult); }
protected void ExportMapDescription(PipelineItem inputSetup) { var payload = InitializePayload(); if (payload is IGraphBasedGeneratorPayload graphBasedGeneratorPayload) { var pipelineItems = new List <PipelineItem> { inputSetup }; PipelineRunner.Run(pipelineItems, graphBasedGeneratorPayload); var levelDescription = graphBasedGeneratorPayload.LevelDescription; var mapDescription = levelDescription.GetMapDescription(); var intMapDescription = GetIntMapDescription(mapDescription); var json = JsonConvert.SerializeObject(intMapDescription, Formatting.Indented, new JsonSerializerSettings() { PreserveReferencesHandling = PreserveReferencesHandling.All, TypeNameHandling = TypeNameHandling.Auto, }); var filename = "exportedMapDescription.json"; File.WriteAllText(filename, json); Debug.Log($"Map description exported to {filename}"); } else { throw new InvalidOperationException($"The payload must implement {nameof(IGraphBasedGeneratorPayload)} to export map descriptions"); } }
public void ExportMapDescription() { var payload = InitializePayload(); var inputSetup = GetInputTask(); var pipelineItems = new List <IPipelineTask <DungeonGeneratorPayload> > { inputSetup }; PipelineRunner.Run(pipelineItems, payload); var levelDescription = payload.LevelDescription; var mapDescription = levelDescription.GetMapDescription(); var intMapDescription = GetIntMapDescription(mapDescription); var json = JsonConvert.SerializeObject(intMapDescription, Formatting.Indented, new JsonSerializerSettings() { PreserveReferencesHandling = PreserveReferencesHandling.All, TypeNameHandling = TypeNameHandling.Auto, }); var filename = "exportedMapDescription.json"; File.WriteAllText(filename, json); Debug.Log($"Map description exported to {filename}"); }
private void BtnRun_Clicked() { if (cancellation != null) { MessageBox.ErrorQuery("Already Running", "Pipeline is already running", "Ok"); return; } runner = new PipelineRunner(_useCase, _pipeline); foreach (var l in additionals) { runner.AdditionalListeners.Add(l); } runner.PipelineExecutionFinishedsuccessfully += Runner_PipelineExecutionFinishedsuccessfully; // clear old results _results.Text = ""; _results.SelectedItem = 0; Task.Run(() => { try { cancellation = new GracefulCancellationTokenSource(); exitCode = runner.Run(activator.RepositoryLocator, this, new FromDataLoadEventListenerToCheckNotifier(this), cancellation.Token); cancellation = null; } catch (Exception ex) { OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, ex.Message, ex)); cancellation = null; } }); }
public void the_pipeline_must_have_been_initialized(Type callGraphGeneratorType) { var pipeline = new PipelineRunner(new InternalDependencyResolver()); Executing(() => pipeline.Run(new InMemoryCommunicationContext())) .ShouldThrow <InvalidOperationException>(); }
public override void Generate() { Debug.Log("--- Generator started ---"); var stopwatch = new Stopwatch(); stopwatch.Start(); var(pipelineItems, payload) = GetPipelineItemsAndPayload(); PipelineRunner.Run(pipelineItems, payload); Debug.Log($"--- Level generated in {stopwatch.ElapsedMilliseconds / 1000f:F}s ---"); }
public void Run_Void_NoInitialValues_CallsInternalRunner() { const string pipelineName = "Pipeline"; var pipeline = new Mock <IPipeline>(); var pipelineRepository = new Mock <IPipelineRepository>(); pipelineRepository.Setup(r => r.Get(pipelineName)).Returns(pipeline.Object); var pipelineContext = new Mock <IPipelineContext>(); var internalPipelineRunner = new Mock <IInternalPipelineRunner>(); internalPipelineRunner .Setup(r => r.Run(pipeline.Object, pipelineContext.Object)) .Callback(() => pipelineContext.Verify(c => c.SetValue(null))); var runner = new PipelineRunner(pipelineName, pipelineRepository.Object, internalPipelineRunner.Object, pipelineContext.Object); runner.Run(); internalPipelineRunner.Verify(r => r.Run(pipeline.Object, pipelineContext.Object)); }
public void Generate() { var pipelineRunner = new PipelineRunner(); pipelineRunner.Run(PipelineItems, PayloadInitializer.InitializePayload()); }