Пример #1
0
        public void ShouldNotDownloadPageIfItDoesntExist()
        {
            //Arrange
            HttpClient         client             = new HttpClient(new HttpMessageHandlerMock());
            DownloadingService downloadingService = new DownloadingService(client);
            LinkInfo           linkInfo           = new LinkInfo {
                Url = "http://en.wikipedia.org"
            };

            //Act
            throw downloadingService.DownloadSourceToFile(linkInfo).Exception.InnerException;
        }
Пример #2
0
        public void ShouldDownloadPage()
        {
            //Arrange
            HttpClient         client             = new HttpClient(new HttpMessageHandlerMock());
            DownloadingService downloadingService = new DownloadingService(client);
            LinkInfo           linkInfo           = new LinkInfo {
                Url = "https://en.wikipedia.org"
            };
            //Act
            var filename = downloadingService.DownloadSourceToFile(linkInfo).Result;

            //Assert
            Assert.IsTrue(File.Exists(filename));
            Assert.IsTrue(File.ReadAllText(filename) == File.ReadAllText("forTest.html"));
        }