public void CanAddANodeByName() { var sumData = new Dictionary <string, object>(); sumData.Add("x", 400.0); sumData.Add("y", 100.0); sumData.Add("name", "Add"); controller.RunCommand(controller.DynamoViewModel.CreateNodeCommand, sumData); Assert.AreEqual(controller.DynamoViewModel.CurrentSpace.Nodes.Count, 1); }
public void CanDiscoverDependenciesForFunctionDefinitionOpenFromFile() { var vm = controller.DynamoViewModel; var examplePath = Path.Combine(ExecutingDirectory, @"..\..\test\dynamo_elements_samples\working\custom_node_dep_test\"); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "RootNode.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "SecondLevelNode1.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "SecondLevelNode2.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "ThirdLevelCustomNodeB1.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "ThirdLevelCustomNodeB2.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "ThirdLevelCustomNodeB3.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "ThirdLevelCustomNodeA1.dyf")) != null); Assert.IsTrue(controller.CustomNodeManager.AddFileToPath(Path.Combine(examplePath, "ThirdLevelCustomNodeA2.dyf")) != null); string openPath = Path.Combine(examplePath, "custom_node_dep_test.dyn"); controller.RunCommand(vm.OpenCommand, openPath); var rootNode = NodeFromCurrentSpace(vm, "333ed3ad-c786-4064-8203-e79ce7cb109f"); Assert.NotNull(rootNode); Assert.IsAssignableFrom(typeof(dynFunction), rootNode); var funcRootNode = rootNode as dynFunction; var dirDeps = funcRootNode.Definition.DirectDependencies; Assert.AreEqual(2, dirDeps.Count()); var allDeps = funcRootNode.Definition.Dependencies; Assert.AreEqual(7, allDeps.Count()); var packageRoot = new PackageItemRootViewModel(funcRootNode.Definition); packageRoot.BuildDependencies(new HashSet <object>()); Assert.AreEqual(2, packageRoot.Items.Count); Assert.AreEqual(2, packageRoot.Items[0].Items.Count); Assert.AreEqual(3, packageRoot.Items[1].Items.Count); }
public void AddSubtractMapReduceFilterBasic() { var vm = controller.DynamoViewModel; string openPath = Path.Combine(GetTestDirectory(), @"dynamo_elements_samples\working\map_reduce_filter\map_reduce_filter.dyn"); controller.RunCommand(vm.OpenCommand, openPath); // check all the nodes and connectors are loaded Assert.AreEqual(28, vm.CurrentSpace.Connectors.Count); Assert.AreEqual(28, vm.CurrentSpace.Nodes.Count); // check an input value var node1 = NodeFromCurrentSpace(vm, "51ed7fed-99fa-46c3-a03c-2c076f2d0538"); Assert.NotNull(node1); Assert.IsAssignableFrom(typeof(dynDoubleInput), node1); Assert.AreEqual("2", ((dynDoubleInput)node1).Value); // run the expression controller.RunCommand(vm.RunExpressionCommand); // wait for the expression to complete Thread.Sleep(500); // check the output values are correctly computed // add-subtract -3.0 var watch = GetWatchNodeFromCurrentSpace(vm, "4a2363b6-ef64-44f5-be64-18832586e574"); var doubleWatchVal = GetDoubleFromFSchemeValue(watch.GetValue(0)); Assert.AreEqual(-3.0, doubleWatchVal); // map - list of three 6's watch = GetWatchNodeFromCurrentSpace(vm, "fcad8d7a-1c9f-4604-a03b-53393e36ea0b"); FSharpList <FScheme.Value> listWatchVal = GetListFromFSchemeValue(watch.GetValue(0)); Assert.AreEqual(3, listWatchVal.Length); Assert.AreEqual(6, GetDoubleFromFSchemeValue(listWatchVal[0])); Assert.AreEqual(6, GetDoubleFromFSchemeValue(listWatchVal[1])); Assert.AreEqual(6, GetDoubleFromFSchemeValue(listWatchVal[2])); // reduce - 6.0 watch = GetWatchNodeFromCurrentSpace(vm, "e892c469-47e6-4006-baea-ec4afea5a04e"); doubleWatchVal = GetDoubleFromFSchemeValue(watch.GetValue(0)); Assert.AreEqual(6.0, doubleWatchVal); // filter - list of 6-10 watch = GetWatchNodeFromCurrentSpace(vm, "41279a88-2f0b-4bd3-bef1-1be693df5c7e"); listWatchVal = GetListFromFSchemeValue(watch.GetValue(0)); Assert.AreEqual(5, listWatchVal.Length); Assert.AreEqual(6, GetDoubleFromFSchemeValue(listWatchVal[0])); Assert.AreEqual(7, GetDoubleFromFSchemeValue(listWatchVal[1])); Assert.AreEqual(8, GetDoubleFromFSchemeValue(listWatchVal[2])); Assert.AreEqual(9, GetDoubleFromFSchemeValue(listWatchVal[3])); Assert.AreEqual(10, GetDoubleFromFSchemeValue(listWatchVal[4])); }