Пример #1
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).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 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.SaveAs(tempPath,
                CurrentDynamoModel.EngineController.LiveRunnerRuntimeCore);

            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));
        }
Пример #3
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));
        }