Esempio n. 1
0
 public async void TestCasePositiveRealRetriever(string text, string[] expectedResults)
 {
     var parser = new LinksParser(new WebsiteTitleRetriever());
     var result = await parser.Parse(text);
     Assert.AreEqual(expectedResults.Length, result.Length);
     for (var i = 0; i < expectedResults.Length; i++)
     {
         Assert.AreEqual(expectedResults[i], ((Link)result[i]).url);
     }
 }
Esempio n. 2
0
        public async void TestCasePositiveMockRetriever(string text, string[] expectedResults)
        {
            var mock = new Mock<ITitleRetriever>(MockBehavior.Strict);
            foreach (var expectedResult in expectedResults)
            {
                mock.Setup(m => m.GetLinkTitle(expectedResult)).Returns(() => Task.FromResult(ExpectedTitle));
            }

            var parser = new LinksParser(mock.Object);
            var result = await parser.Parse(text);
            Assert.AreEqual(expectedResults.Length, result.Length);
            for (var i = 0; i < expectedResults.Length; i++)
            {
                Assert.AreEqual(ExpectedTitle, ((Link)result[i]).title);
                Assert.AreEqual(expectedResults[i], ((Link)result[i]).url);
            }
        }