public void TestNotSupportedProtocol() { var fetcher = new SimpleFetcher(InitConfig()); { Assert.ThrowsException <NotSupportedException>(() => { var file = fetcher.FetchAsync("xxxx://bnu.edu.cn").GetAwaiter().GetResult(); }); } }
public void TestFetch404Page() { var fetcher = new SimpleFetcher(InitConfig()); { Assert.ThrowsException <IOException>(() => { var file = fetcher.FetchAsync("http://www.bnu.edu.cn/xxxxx").GetAwaiter().GetResult(); }); } }
public void TestFetchHttps() { var fetcher = new SimpleFetcher(InitConfig()); { var file = fetcher.FetchAsync("https://www.baidu.com").GetAwaiter().GetResult(); var filePath = file.FilePath; Assert.IsTrue(File.Exists(filePath)); var content = File.ReadAllText(filePath); Assert.IsTrue(content.Contains("百度")); } }