コード例 #1
0
        public void xml_declaration_is_returned()
        {
            const string projectFile = @"regular.csproj.xml";
            var          normalizer  = new VSProjectNormalizer(Settings);
            string       normalized  = normalizer.Normalize(projectFile.GetTestFileInfo());

            Assert.That(normalized, Does.StartWith("<?xml version=\"1.0\" encoding=\"utf-8\"?>"), "xml declaration are omitted");
        }
コード例 #2
0
        public void execution_is_idempotent()
        {
            const string projectFile = @"test.csproj.xml";
            var          normalizer  = new VSProjectNormalizer(Settings);
            var          first       = normalizer.Normalize(projectFile.GetTestFileInfo());

            Assert.AreEqual(first, normalizer.Normalize(first), "second execution is not idempotent");
        }
コード例 #3
0
        public static XElement Normalize(this FileInfo projectFile, Settings settings)
        {
            var    normalizer = new VSProjectNormalizer(settings);
            string normalized = normalizer.Normalize(projectFile);

            File.WriteAllText(
                Path.Combine(Path.GetDirectoryName(projectFile.FullName), Path.GetFileNameWithoutExtension(projectFile.Name)) +
                ".normalized.xml",
                normalized);
            XElement root = XElement.Parse(normalized);

            return(root);
        }
コード例 #4
0
        public void no_namespace_is_added_on_elements()
        {
            const string projectFile = "aspnetcore.csproj.xml";
            var          normalizer  = new VSProjectNormalizer(Settings);
            string       normalized  = normalizer.Normalize(projectFile.GetTestFileInfo());
            XDocument    result      = XDocument.Parse(normalized);

            TestContext.WriteLine(normalized);
            foreach (XElement node in result.Descendants())
            {
                TestContext.WriteLine(node.Name);
                foreach (XAttribute attr in node.Attributes())
                {
                    TestContext.WriteLine($">> {attr}");
                }
            }
        }