Skip to content

Commit

Permalink
moved test to visualization tests
Browse files Browse the repository at this point in the history
- due to node Infos not being updated under a different test base, moved the tests to benefit from the VisualizationTest base
  • Loading branch information
dnenov committed Apr 26, 2024
1 parent 50a876b commit 914b793
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 61 deletions.
61 changes: 0 additions & 61 deletions test/DynamoCoreWpfTests/CustomNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,66 +111,5 @@ public void TestDataInputInitializationTest()
Assert.IsFalse(node.IsAutoMode);
Assert.IsFalse(node.IsList);
}

[Test]
public void TestDefineDataAutoModeType()
{
// Load test graph
string path = Path.Combine(TestDirectory, @"core\defineData\defineDataTest.dyn");
OpenModel(path);

var lockedGUID = "e02596f9-9e1f-43a2-9f61-9909ec58ca34";
var unlockedGUID = "ee557143-64bc-4961-981c-2794af48b79f";

var lockedNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace<DefineData>(
Guid.Parse(lockedGUID));

var unlockedNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace<DefineData>(
Guid.Parse(unlockedGUID));

RunCurrentModel();

var nodes = ViewModel.CurrentSpaceViewModel.Nodes;

Assert.IsFalse(lockedNode.IsAutoMode);
Assert.IsTrue(lockedNode.DisplayValue == "Boolean");
Assert.IsTrue(lockedNode.Infos.Count == 1);

Assert.IsTrue(unlockedNode.IsAutoMode);
Assert.IsTrue(unlockedNode.DisplayValue == "Integer");

// Why is this still showing an internal error?
//Assert.IsTrue(unlockedNode.Infos.Count == 0, "The AutoMode node should have found the correct type and have no Errors, but it does .. ");
}

[Test]
public void TestDefineDataCorrectInheritanceDisplayedInAutoMode()
{
// Load test graph
string path = Path.Combine(TestDirectory, @"core\defineData\defineDataTest.dyn");
OpenModel(path);

var listGUID = "0cbb9f47-5a28-4898-8d28-575cb15c4455"; // List inputs are 'Line' and 'Rectangle', we expect a 'Curve' as DisplayValue
var errorListGUID = "39edfbf6-a83b-4815-9bb0-2d7ebcff39f3"; // List inputs are 'Line', 'Rectangle' and 5 (integer), we expect a 'Select Types' as DisplayValue

var listNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace<DefineData>(
Guid.Parse(listGUID));

var errorListNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace<DefineData>(
Guid.Parse(errorListGUID));

RunCurrentModel();

var nodes = ViewModel.CurrentSpaceViewModel.Nodes;

Assert.IsTrue(listNode.IsAutoMode);
Assert.IsTrue(listNode.IsList);
Assert.AreEqual(listNode.DisplayValue, "Curve", "The correct common ancestor should be Curve, not 'Line' or 'Rectangle'");

Assert.IsTrue(errorListNode.IsAutoMode);
Assert.IsFalse(errorListNode.IsList);
Assert.AreEqual(errorListNode.DisplayValue, "Select Types", "The node displays a type value, but it should not.");
}

}
}
64 changes: 64 additions & 0 deletions test/VisualizationTests/CustomNodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
using CoreNodeModels;
using Dynamo;
using Dynamo.Graph;
using Dynamo.Graph.Nodes;
Expand Down Expand Up @@ -205,4 +207,66 @@ public void InsideInstance_PartiallyApplied_AllGeometryFromInstancesOfThisCustom
Assert.AreEqual(1, BackgroundPreviewGeometry.Meshes().Count(p => p.IsAlive()));
}
}



[TestFixture]
public class CustomNodeDefineDataTests : VisualizationTest
{
[Test]
public void TestDefineDataAutoModeType()
{
var testDirectory = GetTestDirectory(ExecutingDirectory);
var openPath = Path.Combine(testDirectory, @"core\defineData\defineDataTest.dyn");

ViewModel.OpenCommand.Execute(openPath);

var lockedGUID = "e02596f9-9e1f-43a2-9f61-9909ec58ca34";
var unlockedGUID = "ee557143-64bc-4961-981c-2794af48b79f";

var lockedNode = Model.CurrentWorkspace.Nodes.First(n => n.GUID.ToString() == lockedGUID) as DefineData;
var unlockedNode = Model.CurrentWorkspace.Nodes.First(n => n.GUID.ToString() == unlockedGUID) as DefineData;

RunCurrentModel();

var nodes = ViewModel.CurrentSpaceViewModel.Nodes;

Assert.IsFalse(lockedNode.IsAutoMode);
Assert.IsTrue(lockedNode.DisplayValue == "Boolean");
Assert.IsTrue(lockedNode.Infos.Count == 1);

RunCurrentModel();

Assert.IsTrue(unlockedNode.IsAutoMode);
Assert.IsTrue(unlockedNode.DisplayValue == "Integer");
Assert.IsTrue(unlockedNode.Infos.Count == 0, "The AutoMode node should have found the correct type and have no Errors, but it does .. ");
}

[Test]
public void TestDefineDataCorrectInheritanceDisplayedInAutoMode()
{
var testDirectory = GetTestDirectory(ExecutingDirectory);
var openPath = Path.Combine(testDirectory, @"core\defineData\defineDataTest.dyn");

ViewModel.OpenCommand.Execute(openPath);

var listGUID = "0cbb9f47-5a28-4898-8d28-575cb15c4455"; // List inputs are 'Line' and 'Rectangle', we expect a 'Curve' as DisplayValue
var errorListGUID = "39edfbf6-a83b-4815-9bb0-2d7ebcff39f3"; // List inputs are 'Line', 'Rectangle' and 5 (integer), we expect a 'Select Types' as DisplayValue

var listNode = Model.CurrentWorkspace.Nodes.First(n => n.GUID.ToString() == listGUID) as DefineData;
var errorListNode = Model.CurrentWorkspace.Nodes.First(n => n.GUID.ToString() == errorListGUID) as DefineData;

RunCurrentModel();

var nodes = ViewModel.CurrentSpaceViewModel.Nodes;

Assert.IsTrue(listNode.IsAutoMode);
Assert.IsTrue(listNode.IsList);
Assert.AreEqual(listNode.DisplayValue, "Curve", "The correct common ancestor should be Curve, not 'Line' or 'Rectangle'");

Assert.IsTrue(errorListNode.IsAutoMode);
Assert.IsFalse(errorListNode.IsList);
Assert.AreEqual(errorListNode.DisplayValue, "Select Types", "The node displays a type value, but it should not.");
}
}
}

0 comments on commit 914b793

Please sign in to comment.