diff --git a/Bonsai.Core.Tests/InspectBuilderTests.cs b/Bonsai.Core.Tests/InspectBuilderTests.cs index 7c40640f..4a0cc06b 100644 --- a/Bonsai.Core.Tests/InspectBuilderTests.cs +++ b/Bonsai.Core.Tests/InspectBuilderTests.cs @@ -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(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() { diff --git a/Bonsai.Core.Tests/TestWorkflow.cs b/Bonsai.Core.Tests/TestWorkflow.cs index a81ec258..e973c7ed 100644 --- a/Bonsai.Core.Tests/TestWorkflow.cs +++ b/Bonsai.Core.Tests/TestWorkflow.cs @@ -94,6 +94,13 @@ public TestWorkflow AppendNested( return Append(workflowBuilder); } + public TestWorkflow AppendSubject(string name) + where TSubjectBuilder : SubjectExpressionBuilder, new() + { + var subjectBuilder = new TSubjectBuilder { Name = name }; + return Append(subjectBuilder); + } + public ExpressionBuilderGraph ToInspectableGraph() { return Workflow.ToInspectableGraph();