コード例 #1
0
ファイル: BrokenLinkTests.cs プロジェクト: rgregg/apidoctor
        public void BrokenLinkNotFound()
        {
            string markdown =
                @"# Test file

This is a [basic Link](http://www.microsoft.com/).

This is a link to a named resource [ID-based link][microsoft]

This link goes [up one level](../anotherfile.md)

[microsoft]: http://www.microsoft.com
";
            TestableDocFile file = new TestableDocFile(markdown)
            {
                IsLinkValid = new Func <string, bool>(
                    link =>
                {
                    if (link == "../anotherfile.md")
                    {
                        return(false);
                    }
                    return(true);
                })
            };

            var issues = new IssueLogger();

            Assert.IsTrue(file.Scan(string.Empty, issues));
            Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly());

            Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false));
            Assert.AreEqual(1, issues.Issues.WarningsOrErrorsOnly().Count());
            Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound));
        }
コード例 #2
0
ファイル: BrokenLinkTests.cs プロジェクト: rgregg/apidoctor
        public void BrokenLinkInvalidId()
        {
            string markdown =
                @"# Test file

This is a [basic Link](http://www.microsoft.com/).

This is a link to a named resource [ID-based link][microsoft-foo]

This link goes [up one level](../anotherfile.md)

[microsoft]: http://www.microsoft.com
";
            TestableDocFile file = new TestableDocFile(markdown);

            var issues = new IssueLogger();

            Assert.IsTrue(file.Scan(string.Empty, issues));
            var realErrors = from e in issues.Issues where e.IsWarning || e.IsError select e;

            Assert.IsEmpty(realErrors);

            Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false));
            realErrors = from e in issues.Issues where e.IsWarning || e.IsError select e;
            Assert.AreEqual(1, realErrors.Count());
            Assert.IsTrue(realErrors.First().Code == ValidationErrorCode.MissingLinkSourceId);
        }
コード例 #3
0
ファイル: BrokenLinkTests.cs プロジェクト: rgregg/apidoctor
        public void BrokenLinkMultipleErrors()
        {
            var markdown =
                @"# Test file

This is a [basic Link](http://www.microsoft.com/).

This is a link to a named resource [ID-based link][microsoft-foo]

This link goes [up one level](../anotherfile.md)

[microsoft]: http://www.microsoft.com
";
            TestableDocFile file = new TestableDocFile(markdown);

            file.IsLinkValid = link => link != "../anotherfile.md";

            var issues = new IssueLogger();

            Assert.IsTrue(file.Scan(string.Empty, issues));
            Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly());

            Assert.IsFalse(file.ValidateNoBrokenLinks(false, issues, false));
            Assert.AreEqual(2, issues.Issues.WarningsOrErrorsOnly().Count());
            Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.MissingLinkSourceId));
            Assert.IsTrue(issues.Issues.Any(i => i.Code == ValidationErrorCode.LinkDestinationNotFound));
        }
コード例 #4
0
ファイル: BrokenLinkTests.cs プロジェクト: rgregg/apidoctor
        public void NoBrokenLinks()
        {
            string markdown =
                @"# Test file
[Basic Link](http://www.microsoft.com/).
[ID-based link][microsoft]
[Up one level](../anotherfile.md)

[microsoft]: http://www.microsoft.com
";
            TestableDocFile file   = new TestableDocFile(markdown);
            var             issues = new IssueLogger();

            Assert.IsTrue(file.Scan(string.Empty, issues));
            Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly());

            Assert.IsTrue(file.ValidateNoBrokenLinks(false, issues, true));
            Assert.IsEmpty(issues.Issues.WarningsOrErrorsOnly());
        }