コード例 #1
0
        public static LightTestFixture Deserialize(TreeNode <YamlObject> tree)
        {
            var root = new TreeNode <LightScript>();

            var fixture = new LightTestFixture();

            YamlSerializer.DeserializeSimpleProperties(fixture, tree);

            foreach (var yamlScriptNode in tree)
            {
                var s = YamlScriptIO.Deserialize(yamlScriptNode);
                if (s == null || s.Name == null && s.Commands.Count() == 0) // Test fixture name is also part of the tree, so skip it
                {
                    continue;
                }

                fixture.AddScript(Script.FromLightScript(s));
            }

            return(fixture);
        }
コード例 #2
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);
        }