Skip to content

Commit

Permalink
Address failing HelixWatch3DViewModelTests in the WpfVisualizationTes…
Browse files Browse the repository at this point in the history
…ts (#9506)

* add Dynamo Core location to the PATH system environment variable

* All HelixWatch3DViewModel Tests now PASSING!!!

* unsubscribe from Model_EvaluationCompleted in TearDown
  • Loading branch information
alfarok authored Feb 21, 2019
1 parent 5bbdfa1 commit 05647ec
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/VisualizationTests/HelixWatch3DViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ protected override void StartDynamo(TestSessionConfiguration testConfig)
ProcessMode = TaskProcessMode.Synchronous
});

Model.EvaluationCompleted += Model_EvaluationCompleted;

ViewModel = DynamoViewModel.Start(
new DynamoViewModel.StartConfiguration()
{
Expand All @@ -115,6 +117,11 @@ protected override void StartDynamo(TestSessionConfiguration testConfig)
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
}

private async void Model_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
{
DispatcherUtil.DoEvents();
}

protected void OpenVisualizationTest(string fileName)
{
string relativePath = Path.Combine(
Expand All @@ -128,6 +135,13 @@ protected void OpenVisualizationTest(string fileName)

ViewModel.OpenCommand.Execute(relativePath);
}

// With version 2.5 NUnit will call base class TearDown methods after those in the derived classes
[TearDown]
private void CleanUp()
{
Model.EvaluationCompleted -= Model_EvaluationCompleted;
}
}

[TestFixture]
Expand Down Expand Up @@ -183,12 +197,7 @@ public void Node_PreviewToggled_RenderingUpToDate()

OpenVisualizationTest("ASM_points_line.dyn");

DispatcherUtil.DoEvents();

//we start with all previews disabled
//the graph is two points feeding into a line

//ensure that visualizations match our expectations
// Verify that visualizations match our expectations
Assert.True(BackgroundPreviewGeometry.HasNumberOfPointsCurvesAndMeshes(7, 6, 0));

var watch3D = Model.CurrentWorkspace.FirstNodeFromWorkspace<Watch3D>();
Expand All @@ -197,8 +206,7 @@ public void Node_PreviewToggled_RenderingUpToDate()
var view = FindFirstWatch3DNodeView();
var vm = view.ViewModel as HelixWatch3DNodeViewModel;
Assert.NotNull(vm);



Assert.True(vm.SceneItems.HasNumberOfPointsCurvesAndMeshes(0,6,0));
}

Expand Down Expand Up @@ -576,12 +584,9 @@ public void Watch3D_FirstRun()
{
OpenVisualizationTest("FirstRunWatch3D.dyn");

// Clear the dispatcher to ensure that the
// view is created.
DispatcherUtil.DoEvents();

var view = FindFirstWatch3DNodeView();
var vm = view.ViewModel as HelixWatch3DNodeViewModel;

Assert.AreEqual(vm.SceneItems.Count(), 3);
}

Expand All @@ -590,10 +595,6 @@ public void Watch3D_Disconnect_Reconnect_CorrectRenderings()
{
OpenVisualizationTest("ASM_points_line.dyn");

// Clear the dispatcher to ensure that the
// view is created.
DispatcherUtil.DoEvents();

var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

var watch3DNode = ws.FirstNodeFromWorkspace<Watch3D>();
Expand All @@ -618,7 +619,8 @@ public void Watch3D_Disconnect_Reconnect_CorrectRenderings()
ViewModel.Model.ExecuteCommand(cmd1);
ViewModel.Model.ExecuteCommand(cmd2);

Assert.AreEqual(6, view.View.Items.Count);
// View contains 3 default items and a collection of lines from the node connected to the Watch3D node
Assert.AreEqual(4, view.View.Items.Count);
}

[Test]
Expand Down Expand Up @@ -926,13 +928,12 @@ public void CanTagGeometryWhenClickingArrayItemInWatchNode()
tagGeometryWhenClickingItem(new[] { 0 }, 11, "Watch",
n => n.ViewModel.NodeModel.InPorts[0].Connectors[0].Start.Owner);
}

private void tagGeometryWhenClickingItem(int[] indexes, int expectedNumberOfLabels,
private async void tagGeometryWhenClickingItem(int[] indexes, int expectedNumberOfLabels,
string nodeName, Func<NodeView,NodeModel> getGeometryOwnerNode, bool expandPreviewBubble = false)
{
OpenVisualizationTest("MAGN_3815.dyn");
RunCurrentModel();
DispatcherUtil.DoEvents();
Assert.AreEqual(3, Model.CurrentWorkspace.Nodes.Count());
var nodeView = View.ChildrenOfType<NodeView>().First(nv => nv.ViewModel.Name == nodeName);
Assert.IsNotNull(nodeView, "NodeView has not been found by given name: " + nodeName);
Expand Down

0 comments on commit 05647ec

Please sign in to comment.