public void Contains_the_priority_with_the_priority_of_the_url() { var expected = @"<priority>0.7</priority>"; var googleUrl = new GoogleUrl { Priority = 0.7M }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeTrue(); }
public void Does_not_contain_a_priority_tag_if_the_priority_is_null() { var expected = @"<priority"; var googleUrl = new GoogleUrl { Priority = null }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeFalse(); }
public void When_passed_one_url_then_include_xml_for_that_url() { var googleUrl = new GoogleUrl(); var singleUrlSerializerFake = new Mock<IGoogleUrlSerializer>(); singleUrlSerializerFake .Setup(x => x.Serialize(googleUrl)) .Returns("RESULTONE"); var serializer = new GoogleUrlSetSerializer(singleUrlSerializerFake.Object); var result = serializer.Serialize(new[] {googleUrl}); result.Contains("RESULTONE").ShouldBeTrue(); }
public void Contains_the_loc_tag_with_the_location() { var expected = @"<loc>XYZ</loc>"; var googleUrl = new GoogleUrl { Location = "XYZ" }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeTrue(); }
public string Serialize(GoogleUrl googleUrl) { var xml = string.Format(@"<loc>{0}</loc>", googleUrl.Location); if (googleUrl.Priority != null) xml += string.Format(@"<priority>{0}</priority>", googleUrl.Priority); if (googleUrl.ChangeFrequencyOption != ChangeFrequencyOption.NA) xml += string.Format("<changefreq>{0}</changefreq>", googleUrl.ChangeFrequencyOption.ToString().ToLower()); if (googleUrl.LastModified.HasValue) xml += string.Format("<lastmod>{0}</lastmod>", googleUrl.LastModified.Value .ToUniversalTime().ToString("u").Replace(" ", "T")); return string.Format(@"<url>{0}</url>", xml); }
public void Index_returns_serialized_result_from_sitemap_url_provider() { var googleUrls = new GoogleUrl[] {}; var googleUrlProvider = new Mock<IGoogleSiteMapProvider>(); googleUrlProvider.Setup(x => x.GetUrls()) .Returns(googleUrls); var serializerFake = new Mock<IGoogleUrlSetSerializer>(); serializerFake.Setup(x => x.Serialize(googleUrls)) .Returns("EXPECTED"); var controller = new GoogleSiteMapController(serializerFake.Object, googleUrlProvider.Object); var result = controller.Index(); result.ShouldEqual("EXPECTED"); }
public void When_passed_two_urls_then_include_xml_for_those_urls() { var firstUrl = new GoogleUrl(); var secondUrl = new GoogleUrl(); var singleUrlSerializerFake = new Mock<IGoogleUrlSerializer>(); singleUrlSerializerFake .Setup(x => x.Serialize(firstUrl)) .Returns("RESULTONE"); singleUrlSerializerFake .Setup(x => x.Serialize(secondUrl)) .Returns("RESULTTWO"); var serializer = new GoogleUrlSetSerializer(singleUrlSerializerFake.Object); var result = serializer.Serialize(new[] {firstUrl, secondUrl}); result.Contains("RESULTONERESULTTWO").ShouldBeTrue(); }
public void Does_not_include_a_change_freq_tag_when_the_change_frequency_is_NA() { var expected = @"<changefreq"; var googleUrl = new GoogleUrl { ChangeFrequencyOption = ChangeFrequencyOption.NA }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeFalse(); }
public void Includes_a_changefreq_tag_with_the_lower_case_version_of_ChangeFrequency() { var expected = @"<changefreq>always</changefreq>"; var googleUrl = new GoogleUrl { ChangeFrequencyOption = ChangeFrequencyOption.Always }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeTrue(); }
public void Does_not_include_a_last_mod_tag_when_the_LastModified_is_null() { var expected = "<lastmod"; var googleUrl = new GoogleUrl { LastModified = null }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeFalse(); }
public void Includes_a_lastmod_tag_with_the_universal_version_of_LastModified() { var expected = "<lastmod>2010-12-26T05:12:57Z</lastmod>"; var googleUrl = new GoogleUrl { LastModified = new DateTime(2010, 12, 25, 23, 12, 57, 3) }; var serializer = new GoogleUrlSerializer(); var result = serializer.Serialize(googleUrl); result.Contains(expected).ShouldBeTrue(); }