public void XMLSiteMapLoader_PostBodyLoader_Null_Exception() { try { var loader = new XMLSiteMapLoader(new Stubs.SiteMapWebDownloaderStub(), null); Assert.Fail("Очікувалося ArgumentNullException"); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.ParamName == "postBodyLoader"); } }
void _Test_LoadSiteMap(bool upperCaseHTMLBodyForPosts) { string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string fileName = Path.Combine(dir, _SITEMAP_FOLDER, _SITEMAP_FILE_NAME); //имитация карты сайта (здесь будет xml-тело карты для нескольких урл) string body = File.ReadAllText(fileName); var siteMapDown = new Stubs.SiteMapWebDownloaderStub { DontThrowException = true, ResultBody = body }; var postBodyDown = new Stubs.PostBodyLoaderStub { DontThrowException = true }; postBodyDown.URLToBody[_URL_1] = upperCaseHTMLBodyForPosts ? _URL_1_BODY_UPPER : _URL_1_BODY; postBodyDown.URLToBody[_URL_2] = upperCaseHTMLBodyForPosts ? _URL_2_BODY_UPPER : _URL_2_BODY; postBodyDown.URLToBody[_URL_3] = upperCaseHTMLBodyForPosts ? _URL_3_BODY_UPPER : _URL_3_BODY; Dictionary <string, string> urlToTitle = new Dictionary <string, string>(StringComparer.CurrentCultureIgnoreCase) { [_URL_1] = _URL_1_TITLE, [_URL_2] = _URL_2_TITLE, [_URL_3] = _URL_3_TITLE }; var loader = new XMLSiteMapLoader(siteMapDown, postBodyDown); var postInfos = loader.Load(_SITEMAP_POSTS_URL).Result; Assert.IsNotNull(postInfos); Assert.IsTrue(postInfos.Length == postBodyDown.URLToBody.Count); //в реальной карте сайта что-то должно быть: сверить что урл и тайтл передаются foreach (var pi in postInfos) { Assert.IsNotNull(pi); Assert.IsTrue(pi.LastModified != DateTime.MinValue); Assert.IsFalse(string.IsNullOrEmpty(pi.URL)); Assert.IsFalse(string.IsNullOrEmpty(pi.Title)); Assert.IsTrue(pi.Title == urlToTitle[pi.URL]); } }