示例#1
0
        protected override void WriteTestMetadata(XmlWriter writer, IEnumerable <MSTest> tests, string assemblyFilePath)
        {
            writer.WriteStartDocument();

            writer.WriteStartElement("TestLists", @"http://microsoft.com/schemas/VisualStudio/TeamTest/2006");

            writer.WriteStartElement("TestList");
            writer.WriteAttributeString("name", "Lists of Tests");
            writer.WriteAttributeString("id", RootTestListGuid.ToString());

            writer.WriteEndElement();

            writer.WriteStartElement("TestList");
            writer.WriteAttributeString("id", SelectedTestListGuid.ToString());
            writer.WriteAttributeString("name", SelectedTestListName);
            writer.WriteAttributeString("parentListId", RootTestListGuid.ToString());
            writer.WriteStartElement("TestLinks");

            foreach (MSTest test in tests)
            {
                if (test.IsTestCase)
                {
                    writer.WriteStartElement("TestLink");
                    writer.WriteAttributeString("id", test.Guid.ToString());
                    writer.WriteAttributeString("name", test.TestName);
                    writer.WriteAttributeString("storage", assemblyFilePath);
                    writer.WriteAttributeString("type",
                                                "Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, PublicKeyToken=b03f5f7f11d50a3a");
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteEndDocument();
        }
        protected override void WriteTestMetadata(XmlWriter writer, IEnumerable <MSTest> tests, string assemblyFilePath)
        {
            writer.WriteStartDocument();

            writer.WriteStartElement("Tests");

            writer.WriteStartElement("edtdocversion");
            writer.WriteAttributeString("branch", "retail");
            writer.WriteAttributeString("build", "50727");
            writer.WriteAttributeString("revision", "1433");
            writer.WriteEndElement();

            writer.WriteStartElement("TestCategory");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategory");

            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategoryId");
            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "System.Guid");
            writer.WriteValue(RootTestListGuid.ToString());
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteStartElement("name");
            writer.WriteAttributeString("type", "System.String");
            writer.WriteValue("List of Tests");
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            writer.WriteAttributeString("type", "System.String");
            writer.WriteEndElement();

            writer.WriteStartElement("enabled");
            writer.WriteAttributeString("type", "System.Boolean");
            writer.WriteValue("True");
            writer.WriteEndElement();

            writer.WriteStartElement("parentCategoryId");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategoryId");
            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "System.Guid");
            writer.WriteValue("00000000-0000-0000-0000-000000000000");
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteEndElement(); // TestCategory

            writer.WriteStartElement("TestCategory");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategory");

            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategoryId");
            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "System.Guid");
            writer.WriteValue(SelectedTestListGuid.ToString());
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteStartElement("name");
            writer.WriteAttributeString("type", "System.String");
            writer.WriteValue(SelectedTestListName);
            writer.WriteEndElement();

            writer.WriteStartElement("description");
            writer.WriteAttributeString("type", "System.String");
            writer.WriteEndElement();

            writer.WriteStartElement("enabled");
            writer.WriteAttributeString("type", "System.Boolean");
            writer.WriteValue("True");
            writer.WriteEndElement();

            writer.WriteStartElement("parentCategoryId");
            writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.TestCategoryId");
            writer.WriteStartElement("id");
            writer.WriteAttributeString("type", "System.Guid");
            writer.WriteValue(RootTestListGuid.ToString());
            writer.WriteEndElement();
            writer.WriteEndElement();

            writer.WriteStartElement("testLinks");
            writer.WriteAttributeString("type", "System.Collections.Hashtable");

            foreach (MSTest test in tests)
            {
                if (test.IsTestCase)
                {
                    writer.WriteStartElement("key");
                    writer.WriteAttributeString("type", "System.Guid");
                    writer.WriteValue(test.Guid.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("value");
                    writer.WriteAttributeString("type", "Microsoft.VisualStudio.TestTools.Common.Link");

                    writer.WriteStartElement("id");
                    writer.WriteAttributeString("type", "System.Guid");
                    writer.WriteValue(test.Guid.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("name");
                    writer.WriteAttributeString("type", "System.String");
                    writer.WriteValue(test.TestName);
                    writer.WriteEndElement();

                    writer.WriteStartElement("storage");
                    writer.WriteAttributeString("type", "System.String");
                    writer.WriteValue(assemblyFilePath);
                    writer.WriteEndElement();

                    writer.WriteStartElement("type");
                    writer.WriteAttributeString("type", "System.Type, mscorlib");
                    writer.WriteValue("Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestElement, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                    writer.WriteEndElement();

                    writer.WriteStartElement("enabled");
                    writer.WriteAttributeString("type", "System.Boolean");
                    writer.WriteValue("True");
                    writer.WriteEndElement();

                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement(); // testLinks

            writer.WriteEndElement(); // TestCategory

            writer.WriteEndElement(); // Tests

            writer.WriteEndDocument();
        }