Esempio n. 1
0
        private void Verify(PortToDocsTestData testData)
        {
            string[] expectedLines = File.ReadAllLines(testData.ExpectedFilePath);
            string[] actualLines   = File.ReadAllLines(testData.ActualFilePath);

            for (int i = 0; i < expectedLines.Length; i++)
            {
                Assert.True(i < expectedLines.Length);
                Assert.True(i < actualLines.Length);

                string expectedLine = expectedLines[i];
                string actualLine   = actualLines[i];

                // Print some more details before asserting
                if (expectedLine != actualLine)
                {
                    string expected = GetProblematicLines("Expected", expectedLines, i);
                    string actual   = GetProblematicLines("Actual", actualLines, i);

                    Output.WriteLine(expected);
                    Output.WriteLine(actual);
                }

                Assert.Equal(expectedLine, actualLine);
            }

            // Check at the end, because we first want to fail on different lines
            Assert.Equal(expectedLines.Length, actualLines.Length);
        }
Esempio n. 2
0
        private void PortToDocs(
            string testDataDir,
            bool disablePrompts = true,
            bool printUndoc     = false,
            bool save           = true,
            bool skipInterfaceImplementations = true,
            bool skipInterfaceRemarks         = true,
            bool portTypeRemarks            = true,
            bool portMemberRemarks          = true,
            bool portExceptionsExisting     = false,
            int exceptionCollisionThreshold = 70,
            string assemblyName             = TestData.TestAssembly,
            string namespaceName            = null, // Most namespaces have the same assembly name
            string typeName = TestData.TestType)
        {
            using TestDirectory tempDir = new TestDirectory();

            PortToDocsTestData testData = new PortToDocsTestData(
                tempDir,
                testDataDir,
                skipInterfaceImplementations: skipInterfaceImplementations,
                assemblyName: assemblyName,
                namespaceName: namespaceName,
                typeName: typeName
                );

            Configuration c = new()
            {
                Direction      = Configuration.PortingDirection.ToDocs,
                DisablePrompts = disablePrompts,
                ExceptionCollisionThreshold = exceptionCollisionThreshold,
                PortExceptionsExisting      = portExceptionsExisting,
                PortMemberRemarks           = portMemberRemarks,
                PortTypeRemarks             = portTypeRemarks,
                PrintUndoc = printUndoc,
                Save       = save,
                SkipInterfaceImplementations = skipInterfaceImplementations,
                SkipInterfaceRemarks         = skipInterfaceRemarks
            };

            c.IncludedAssemblies.Add(assemblyName);

            if (!string.IsNullOrEmpty(namespaceName))
            {
                c.IncludedNamespaces.Add(namespaceName);
            }

            c.DirsDocsXml.Add(testData.DocsDir);
            c.DirsIntelliSense.Add(testData.IntelliSenseAndDLLDir);

            var porter = new ToDocsPorter(c);

            porter.Start();

            Verify(testData);
        }