Ejemplo n.º 1
0
        public static TreeNode<YamlObject> Serialize(LightScript script, int level = 0)
        {
            var scriptObject = new YamlObject(level, script.GetType().Name, "");
            var tree = new TreeNode<YamlObject>(scriptObject);

            foreach (var n in YamlSerializer.SerializeSimpleProperties(script, level + 1))
                tree.AddChild(n);

            foreach (var node in script.Commands)
                SerializeCommandsRecursively(tree, node, level + 1);

            return tree;
        }
Ejemplo n.º 2
0
        public static TreeNode <YamlObject> Serialize(Command command, int level)
        {
            var commandObject = new YamlObject(level, command.GetType().Name, "");
            var tree          = new TreeNode <YamlObject>(commandObject);

            tree.AddChild(new YamlObject(level + 1, "<Guid>k__BackingField", command.Guid));

            var objs = YamlSerializer.SerializeSimpleProperties(command, level + 1);

            foreach (var o in objs)
            {
                tree.AddChild(o);
            }

            return(tree);
        }
Ejemplo n.º 3
0
        private static void DeserializeYamlLinesRecursively(TreeNode <YamlObject> root, string[] lines, int startIndex)
        {
            var level          = GetLevel(lines[startIndex]);
            var yamlObject     = new YamlObject(lines[startIndex]);
            var yamlObjectNode = root.AddChild(yamlObject);

            for (int i = startIndex + 1; i < lines.Length; ++i)
            {
                var currentLineLevel = GetLevel(lines[i]);
                if (level + 1 == currentLineLevel) // Adding childs to currently added yamlObject
                {
                    DeserializeYamlLinesRecursively(yamlObjectNode, lines, i);
                }
                else if (level + 1 < currentLineLevel)
                {
                    continue;
                }
                else if (level + 1 > currentLineLevel)
                {
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public static TreeNode <YamlObject> Serialize(LightTestFixture fixture)
        {
            var level         = 0;
            var fixtureObject = new YamlObject(level, fixture.GetType().Name, "");
            var tree          = new TreeNode <YamlObject>(fixtureObject);

            foreach (var n in YamlSerializer.SerializeSimpleProperties(fixture, level + 1))
            {
                tree.AddChild(n);
            }

            tree.Join(YamlScriptIO.Serialize(fixture.Setup.ToLightScript(), level + 1));
            tree.Join(YamlScriptIO.Serialize(fixture.TearDown.ToLightScript(), level + 1));
            tree.Join(YamlScriptIO.Serialize(fixture.OneTimeSetup.ToLightScript(), level + 1));
            tree.Join(YamlScriptIO.Serialize(fixture.OneTimeTeardown.ToLightScript(), level + 1));

            foreach (var t in fixture.Tests)
            {
                tree.Join(YamlScriptIO.Serialize(t.ToLightScript(), level + 1));
            }

            return(tree);
        }