Skip to content

Commit

Permalink
Merge pull request #1964 from glopesdev/test-infrastructure
Browse files Browse the repository at this point in the history
Add support for sorting test workflows
  • Loading branch information
glopesdev authored Aug 30, 2024
2 parents 6007a9c + a0581ba commit b8ece22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Bonsai.Core.Tests/TestWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public TestWorkflow AppendSubject<TSubjectBuilder>(string name)
return Append(subjectBuilder);
}

public TestWorkflow TopologicalSort()
{
var workflow = new ExpressionBuilderGraph();
workflow.InsertRange(0, Workflow.TopologicalSort());
return new TestWorkflow(workflow, Cursor);
}

public ExpressionBuilderGraph ToInspectableGraph()
{
return Workflow.ToInspectableGraph();
Expand Down
9 changes: 2 additions & 7 deletions Bonsai.Editor.Tests/WorkflowEditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ static string ToString(IEnumerable<T> sequence)
ExpressionBuilderGraph workflow = null,
MockGraphView graphView = null)
{
if (workflow != null)
{
// Workflows must be topologically sorted to ensure all editor operations are reversible
workflow.InsertRange(0, workflow.TopologicalSort());
}

graphView ??= new MockGraphView(workflow);
var editor = new WorkflowEditor(graphView.ServiceProvider, graphView);
editor.UpdateLayout.Subscribe(graphView.UpdateGraphLayout);
Expand Down Expand Up @@ -236,7 +230,7 @@ public void ReplaceGraphNode_SingleInputWithVisualizerMapping_GroupWorkflowHasSi
.AppendBranch(source => source
.AppendSubject<Reactive.PublishSubject>("P")
.AddArguments(source.Append(new VisualizerMappingBuilder())))
.Workflow
.TopologicalSort()
.ToInspectableGraph();

var (editor, assertIsReversible) = CreateMockEditor(workflow);
Expand All @@ -252,6 +246,7 @@ public void ReplaceGraphNode_SingleInputWithVisualizerMapping_GroupWorkflowHasSi
var groupBuilder = ExpressionBuilder.Unwrap(groupNode?.Value) as GroupWorkflowBuilder;
Assert.IsInstanceOfType(groupBuilder, typeof(GroupWorkflowBuilder));
Assert.AreEqual(expected: 2, groupBuilder.Workflow.Count);
Assert.IsInstanceOfType(ExpressionBuilder.Unwrap(groupBuilder.Workflow[0].Value), typeof(WorkflowInputBuilder));
Assert.IsInstanceOfType(ExpressionBuilder.Unwrap(groupBuilder.Workflow[1].Value), typeof(WorkflowOutputBuilder));
assertIsReversible();
}
Expand Down

0 comments on commit b8ece22

Please sign in to comment.