Ejemplo n.º 1
0
        public void GetRemarks_ReturnsExpectedRemarks(string id, string expectedRemarks)
        {
            // Arrange
            var xmlDocumentationProvider = new XmlDocumentationProvider(XmlTestFileLocation);

            // Act
            var remarks = xmlDocumentationProvider.GetRemarks(id);

            // Assert
            Assert.Equal(expectedRemarks, remarks, StringComparer.Ordinal);
        }
Ejemplo n.º 2
0
        private static DocumentationDescriptor CreateDocumentationDescriptor(Assembly assembly, string id)
        {
            var assemblyLocation = assembly.Location;

            if (string.IsNullOrEmpty(assemblyLocation) && !string.IsNullOrEmpty(assembly.CodeBase))
            {
                var uri = new UriBuilder(assembly.CodeBase);

                // Normalize the path to a UNC path. This will remove things like file:// from start of the uri.Path.
                assemblyLocation = Uri.UnescapeDataString(uri.Path);
            }

            // Couldn't resolve a valid assemblyLocation.
            if (string.IsNullOrEmpty(assemblyLocation))
            {
                return(null);
            }

            var xmlDocumentationFile = GetXmlDocumentationFile(assembly, assemblyLocation);

            // Only want to process the file if it exists.
            if (xmlDocumentationFile != null)
            {
                var documentationProvider = new XmlDocumentationProvider(xmlDocumentationFile.FullName);

                var summary = documentationProvider.GetSummary(id);
                var remarks = documentationProvider.GetRemarks(id);

                if (!string.IsNullOrEmpty(summary) || !string.IsNullOrEmpty(remarks))
                {
                    return(new DocumentationDescriptor
                    {
                        Summary = summary,
                        Remarks = remarks
                    });
                }
            }

            return(null);
        }
        private static DocumentationDescriptor CreateDocumentationDescriptor(Assembly assembly, string id)
        {
            var assemblyLocation = assembly.Location;

            if (string.IsNullOrEmpty(assemblyLocation) && !string.IsNullOrEmpty(assembly.CodeBase))
            {
                var uri = new UriBuilder(assembly.CodeBase);

                // Normalize the path to a UNC path. This will remove things like file:// from start of the uri.Path.
                assemblyLocation = Uri.UnescapeDataString(uri.Path);
            }

            // Couldn't resolve a valid assemblyLocation.
            if (string.IsNullOrEmpty(assemblyLocation))
            {
                return null;
            }

            var xmlDocumentationFile = GetXmlDocumentationFile(assembly, assemblyLocation);

            // Only want to process the file if it exists.
            if (xmlDocumentationFile != null)
            {
                var documentationProvider = new XmlDocumentationProvider(xmlDocumentationFile.FullName);

                var summary = documentationProvider.GetSummary(id);
                var remarks = documentationProvider.GetRemarks(id);

                if (!string.IsNullOrEmpty(summary) || !string.IsNullOrEmpty(remarks))
                {
                    return new DocumentationDescriptor
                    {
                        Summary = summary,
                        Remarks = remarks
                    };
                }
            }

            return null;
        }
        public void GetRemarks_ReturnsExpectedRemarks(string id, string expectedRemarks)
        {
            // Arrange
            var xmlDocumentationProvider = new XmlDocumentationProvider(XmlTestFileLocation);

            // Act
            var remarks = xmlDocumentationProvider.GetRemarks(id);

            // Assert
            Assert.Equal(expectedRemarks, remarks, StringComparer.Ordinal);
        }