Пример #1
0
        public async Task FetchPreviewFromUrlAsync_SuccessOnMultipleUrls()
        {
            var urlPreview = new UrlPreview();
            var task1      = await urlPreview.FetchPreviewFromUrlAsync("https://www.cnn.com");

            Assert.NotNull(task1);
            Assert.NotNull(task1.Title);
            Assert.NotNull(task1.Description);

            var task2 = await urlPreview.FetchPreviewFromUrlAsync("https://www.foxnews.com");

            Assert.NotNull(task2);
            Assert.NotNull(task2.Title);
            Assert.NotNull(task2.Description);

            var task3 = await urlPreview.FetchPreviewFromUrlAsync("https://www.bloomberg.com");

            Assert.NotNull(task3);
            Assert.NotNull(task3.Title);
            Assert.NotNull(task3.Description);

            var task4 = await urlPreview.FetchPreviewFromUrlAsync("https://techcrunch.com");

            Assert.NotNull(task4);
            Assert.NotNull(task4.Title);
            Assert.NotNull(task4.Description);
        }
Пример #2
0
        public async Task FetchPreviewFromUrlAsync_FailsOnInvalidUrl()
        {
            var urlPreview = new UrlPreview();
            var task1      = await urlPreview.FetchPreviewFromUrlAsync("");

            Assert.Null(task1);

            var task2 = await urlPreview.FetchPreviewFromUrlAsync(null as string);

            Assert.Null(task2);

            var task3 = await urlPreview.FetchPreviewFromUrlAsync(null as Uri);

            Assert.Null(task3);

            await Assert.ThrowsAsync <Exception>(() => urlPreview.FetchPreviewFromUrlAsync("this is not a url lol;;;$$$$#$"));
        }