Skip to content

Commit

Permalink
Regression test for defer with nested visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jul 19, 2024
1 parent 642ba8c commit 297552e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Bonsai.Core.Tests/InspectBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,33 @@ public void Build_DeferInspectBuilder_ReturnNestedVisualizerElement()
Assert.AreSame(target, visualizerElement.Builder);
}

[TestMethod]
public void Build_DeferWithNestedVisualizerInspectBuilder_ReturnNestedVisualizerElement()
{
// related to https://github.com/bonsai-rx/bonsai/issues/1896
ExpressionBuilder target = null;
var workflow = new TestWorkflow()
.AppendUnit()
.AppendNested(
input => input
.AppendUnit()
.AppendSubject<Reactive.BehaviorSubject>(nameof(System.Reactive.Unit))
.AppendNested(
input => input
.AppendUnit()
.Capture(out target)
.AppendOutput(),
workflow => new Reactive.Visualizer(workflow))
.AppendOutput(),
workflow => new Reactive.Defer(workflow))
.ToInspectableGraph();
workflow.Build();

var output = workflow[workflow.Count - 1].Value;
var visualizerElement = ExpressionBuilder.GetVisualizerElement(output);
Assert.AreSame(target, visualizerElement.Builder);
}

[TestMethod]
public void Build_PropertyMappedInspectBuilderToWorkflowOutput_ReturnVisualizerElement()
{
Expand Down
7 changes: 7 additions & 0 deletions Bonsai.Core.Tests/TestWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public TestWorkflow AppendNested<TWorkflowExpressionBuilder>(
return Append(workflowBuilder);
}

public TestWorkflow AppendSubject<TSubjectBuilder>(string name)
where TSubjectBuilder : SubjectExpressionBuilder, new()
{
var subjectBuilder = new TSubjectBuilder { Name = name };
return Append(subjectBuilder);
}

public ExpressionBuilderGraph ToInspectableGraph()
{
return Workflow.ToInspectableGraph();
Expand Down

0 comments on commit 297552e

Please sign in to comment.