コード例 #1
0
ファイル: DateTimeTests.cs プロジェクト: zjloscar/Dynamo
        public void DateTimeNode_Open_Edit_SerializesCorrectly()
        {
            var path = Path.Combine(TestDirectory, "core", "dateTime", "DateTime.dyn");

            CurrentDynamoModel.OpenFileFromPath(path);

            var node     = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <DateTime>();
            var testDate = new System.DateTime(2150, 1, 1, 12, 0, 0).ToUniversalTime();

            node.Value = testDate;
            Assert.IsTrue(node.Value.Kind == System.DateTimeKind.Utc, " DateTime Value should be UTC kind");

            CurrentDynamoModel.CurrentWorkspace.Save(tempPath);

            var fileContents = File.ReadAllText(tempPath);

            fileContents = fileContents.Trim();
            if ((fileContents.StartsWith("{") && fileContents.EndsWith("}")) || //For object
                (fileContents.StartsWith("[") && fileContents.EndsWith("]")))   //For array
            {
                var obj = Newtonsoft.Json.Linq.JToken.Parse(fileContents);
                Assert.IsTrue(obj["Inputs"][0].ToString().Contains("Z"),
                              "DateTime Nodes serialization incorrectly in Inputs Block: " + obj["Inputs"][0].ToString());
                Assert.IsTrue(obj["Nodes"][0].ToString().Contains("Z"),
                              "DateTime Nodes serialization incorrectly in Nodes Block: " + obj["Nodes"][0].ToString());
            }

            CurrentDynamoModel.OpenFileFromPath(tempPath);

            node = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <DateTime>();
            Assert.IsTrue(node.Value.Kind == System.DateTimeKind.Utc, " DateTime Value should be UTC kind");
            var dt = (System.DateTime)GetPreviewValue(node.GUID.ToString());

            Assert.AreEqual(string.Format("{0:" + PreferenceSettings.DefaultDateFormat + "}", dt), testDate.ToString(PreferenceSettings.DefaultDateFormat));
        }
コード例 #2
0
        public void DynamoPrintLogsToConsole()
        {
            var expectedOutput = "Greeting CPython node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython node: Hello from Python2!!!" + Environment.NewLine
                                 + "Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython String node: Hello from Python2!!!" + Environment.NewLine;

            CurrentDynamoModel.OpenFileFromPath(Path.Combine(TestDirectory, "core", "python", "DynamoPrint.dyn"));
            StringAssert.EndsWith(expectedOutput, CurrentDynamoModel.Logger.LogText);
        }
コード例 #3
0
ファイル: DateTimeTests.cs プロジェクト: zjloscar/Dynamo
        public void DateTimeNodeDeprecated_Test()
        {
            var path = Path.Combine(TestDirectory, "core", "dateTime", "DateTimeDeprecated.dyn");

            CurrentDynamoModel.OpenFileFromPath(path);

            var node = CurrentDynamoModel.CurrentWorkspace.Nodes.FirstOrDefault();

            Assert.IsNotNull(node);
            Assert.AreEqual(ElementState.PersistentWarning, node.State);
            Assert.AreEqual("This node is deprecated", node.ToolTipText);
        }
コード例 #4
0
        public void DynamoPrintLogsToConsole()
        {
            var expectedOutput = ".*Greeting CPython node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + ".*Multiple print parameter node: Hello Dynamo Print !!!" + Environment.NewLine
                                 + ".*Print separator parameter node: Hello_Dynamo_Print_!!!" + Environment.NewLine
                                 + ".*`!\"£\\$%\\^&\\*\\(\\)_\\+-\\[\\{\\]\\}#~'@;:\\|\\\\,<\\.>/\\? Special character node: Lot's of special characters!!!" + Environment.NewLine
                                 + ".*";

            CurrentDynamoModel.OpenFileFromPath(Path.Combine(TestDirectory, "core", "python", "DynamoPrint.dyn"));
            StringAssert.IsMatch(expectedOutput, CurrentDynamoModel.Logger.LogText);
        }
コード例 #5
0
        public void DynamoPrintLogsToConsole()
        {
            var expectedOutput = "Greeting CPython node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython node: Hello from Python2!!!" + Environment.NewLine
                                 + "Greeting CPython String node: Hello from Python3!!!" + Environment.NewLine
                                 + "Greeting IronPython String node: Hello from Python2!!!" + Environment.NewLine
                                 + "Multiple print parameter node: Hello Dynamo Print !!!" + Environment.NewLine
                                 + "Print separator parameter node: Hello_Dynamo_Print_!!!" + Environment.NewLine
                                 + @"`!""£$%^&*()_+-[{]}#~'@;:|\,<.>/? Special character node: Lot's of special characters!!!" + Environment.NewLine;

            CurrentDynamoModel.OpenFileFromPath(Path.Combine(TestDirectory, "core", "python", "DynamoPrint.dyn"));
            StringAssert.EndsWith(expectedOutput, CurrentDynamoModel.Logger.LogText);
        }
コード例 #6
0
ファイル: CoreDynTests.cs プロジェクト: reddyashish/Dynamo
        public void verifyNodeStates()
        {
            // Open/Run XML test graph
            string openPath = Path.Combine(TestDirectory, @"core\NodeStates.dyn");

            RunModel(openPath);

            // Check dead node XML
            var deadNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("1237a148-7a90-489d-b677-11038072c288");

            Assert.AreEqual(ElementState.Dead, deadNode.State);
            // Check warning node XML
            var warningNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("50219c24-e583-4b85-887c-409fb062da6e");

            Assert.AreEqual(ElementState.Warning, warningNode.State);
            // Check active node XML
            var activeNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("b51b283a-f6ce-4717-9525-4cf8c8e92934");

            Assert.AreEqual(ElementState.Active, activeNode.State);

            // Save/Open/Run JSON graph
            string tempPath = Path.Combine(Path.GetTempPath(), "NodeStates.dyn");

            CurrentDynamoModel.CurrentWorkspace.Save(tempPath);
            CurrentDynamoModel.OpenFileFromPath(tempPath);
            CurrentDynamoModel.CurrentWorkspace.RequestRun();


            // Check dead node JSON
            deadNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("1237a148-7a90-489d-b677-11038072c288");
            Assert.AreEqual(ElementState.Dead, deadNode.State);
            // Check warning node JSON
            warningNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("50219c24-e583-4b85-887c-409fb062da6e");
            Assert.AreEqual(ElementState.Warning, warningNode.State);
            // Check active node JSON
            activeNode = CurrentDynamoModel.CurrentWorkspace.NodeFromWorkspace("b51b283a-f6ce-4717-9525-4cf8c8e92934");
            Assert.AreEqual(ElementState.Active, activeNode.State);


            // Delete temp graph file
            File.Delete(tempPath);
        }
コード例 #7
0
        public void DateTimeNode_Open_Edit_SerializesCorrectly()
        {
            var path = Path.Combine(TestDirectory, "core", "dateTime", "DateTime.dyn");

            CurrentDynamoModel.OpenFileFromPath(path);

            var node     = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <DateTime>();
            var testDate = new System.DateTime(2150, 1, 1, 12, 0, 0);

            node.Value = testDate;

            CurrentDynamoModel.CurrentWorkspace.Save(tempPath);

            CurrentDynamoModel.OpenFileFromPath(tempPath);

            node = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace <DateTime>();
            var dt = (System.DateTime)GetPreviewValue(node.GUID.ToString());

            Assert.AreEqual(string.Format("{0:" + PreferenceSettings.DefaultDateFormat + "}", dt), testDate.ToString(PreferenceSettings.DefaultDateFormat));
        }
コード例 #8
0
        public void TestWorkspaceMigrationAttribute()
        {
            //Arrange
            DynamoModel.EnableMigrationLogging = true;
            string openPath = string.Empty;
            string tempPath = string.Empty;

            try
            {
                openPath = Path.Combine(TestDirectory, @"core\nodeLocationTest.dyn");
                tempPath = Path.Combine(Path.GetTempPath(), "nodeLocationTest.dyn");

                //Act
                // Open/Run XML test graph
                RunModel(openPath);

                // Save/Open/Run JSON graph
                CurrentDynamoModel.CurrentWorkspace.Save(tempPath);
                CurrentDynamoModel.OpenFileFromPath(tempPath);
                CurrentDynamoModel.CurrentWorkspace.RequestRun();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                //Assert
                //This flag needs to be set to false because if not the next test cases will start to fail
                DynamoModel.EnableMigrationLogging = false;

                //Check that the file exists
                Assert.IsTrue(File.Exists(Path.Combine(TestDirectory, @"core\MigrationLog_nodeLocationTest.xml")));//Validate the MigrationReport.WriteToXmlFile

                if (File.Exists(tempPath))
                {
                    // Delete temp graph file
                    File.Delete(tempPath);
                }
            }
        }
コード例 #9
0
        public void RunSettingsDisableAndEnableRun()
        {
            string openPath = Path.Combine(TestDirectory, @"core\RunSettings.dyn");

            CurrentDynamoModel.OpenFileFromPath(openPath);

            var ws = CurrentDynamoModel.CurrentWorkspace as HomeWorkspaceModel;

            Assert.AreEqual(0, ws.EvaluationCount);

            // Still in Manual mode so will not run
            ws.RequestRun();
            Assert.AreEqual(0, ws.EvaluationCount);

            // Setting the run type to automatic
            // This will not trigger the Run() function because there is a no handle for that proptery in the dynamo model test.
            ws.RunSettings.RunType = RunType.Automatic;

            ws.RunSettings.RunEnabled = false;
            // This should not run
            ws.RequestRun();
            Assert.AreEqual(0, ws.EvaluationCount);

            // Modifying the graph shouldn't trigger the run as runenabled is still false.
            Guid      codeBlockNodeGuid = Guid.Parse("deb0ae37d6974ef4a88e5d35a5c5ce42");
            NodeModel codeBlockNode     = ws.NodeFromWorkspace(codeBlockNodeGuid);

            codeBlockNode.UpdateValue(new UpdateValueParams("Code", "10;"));
            Assert.AreEqual(0, ws.EvaluationCount);

            ws.RunSettings.RunEnabled = true;
            // This should run
            ws.RequestRun();
            Assert.AreEqual(1, ws.EvaluationCount);

            // Modifying the graph will run it again.
            codeBlockNode.UpdateValue(new UpdateValueParams("Code", "15;"));
            Assert.AreEqual(2, ws.EvaluationCount);
        }
コード例 #10
0
        public void TestWorkspaceMigrationAttribute()
        {
            //Arrange
            DynamoModel.EnableMigrationLogging = true;
            string openPath = Path.Combine(TestDirectory, @"core\nodeLocationTest.dyn");

            //Act
            // Open/Run XML test graph
            RunModel(openPath);

            // Save/Open/Run JSON graph
            string tempPath = Path.Combine(Path.GetTempPath(), "nodeLocationTest.dyn");

            CurrentDynamoModel.CurrentWorkspace.Save(tempPath);
            CurrentDynamoModel.OpenFileFromPath(tempPath);
            CurrentDynamoModel.CurrentWorkspace.RequestRun();

            //Assert
            //Check that the file exists
            Assert.IsTrue(File.Exists(Path.Combine(TestDirectory, @"core\MigrationLog_nodeLocationTest.xml")));//Validate the MigrationReport.WriteToXmlFile

            // Delete temp graph file
            File.Delete(tempPath);
        }