Пример #1
0
        public void YamlObject_ProducesCorrect_Script()
        {
            var s           = Script;
            var lightScript = s.ToLightScript();
            var yamlObj     = YamlScriptIO.Serialize(s);
            var newScript   = YamlScriptIO.Deserialize(yamlObj);

            Assert.AreEqual(lightScript.Commands.Count(), newScript.Commands.Count(), "Command count should be the same.");
        }
Пример #2
0
        public void Script_ProducesCorrect_YamlString()
        {
            var yamlObj    = YamlScriptIO.Serialize(Script.ToLightScript());
            var yamlString = YamlSerializer.SerializeYamlTree(yamlObj);

            // Needed to ignore randomly generated guids
            var expected = Regex.Replace(serializedScript, RegexExpression.Guid, new Guid().ToString(), RegexOptions.Multiline | RegexOptions.IgnoreCase);
            var actual   = Regex.Replace(yamlString, RegexExpression.Guid, new Guid().ToString(), RegexOptions.Multiline | RegexOptions.IgnoreCase);

            StringAssert.Contains(actual, expected, "Strings missmatched.");
        }
Пример #3
0
        public void Script_ProducesCorrect_YamlObj()
        {
            var yamlObj  = YamlScriptIO.Serialize(Script.ToLightScript());
            var children = yamlObj.ToArray();

            Assert.AreEqual(4, children.Length, "only two root commands should be in the script and a name.");

            Assert.AreEqual(guid.ToString(), children[0].value.value, "Guid value was incorrect");
            Assert.AreEqual("TestName", children[1].value.value, "Test name value was incorrect");
            Assert.AreEqual(4, children[2].ToArray().Length, "Image command has also three childs, timeout CommandPress, and two guids");
            Assert.AreEqual(3, children[3].ToArray().Length, "Command move has also two childs, X and Y and guid.");

            var commandPress = children[2].ToArray()[3];

            Assert.AreEqual("CommandPress", commandPress.value.property, "CommandPress value of YamlObject was incorrect");
            Assert.AreEqual(5, commandPress.ToArray().Length, "CommandPress has 5 childs, X Y DontMove, guid, mouse buttons");
        }