public void WebpageUrlGenerator_GetDocumentUrlWithExistingName_ShouldReturnTheUrlWithADigitAppended() { var parent = new BasicMappedWebpage { Name = "Parent", UrlSegment = "parent", Site = CurrentSite }; var textPage = new BasicMappedWebpage { Name = "Test Page", Parent = parent, UrlSegment = "parent/test-page", Site = CurrentSite }; Session.Transact(session => { session.SaveOrUpdate(parent); session.SaveOrUpdate(textPage); }); A.CallTo(() => _urlValidationService.UrlIsValidForWebpage("parent/test-page/nested-page", null)) .Returns(false); string documentUrl = _webpageUrlService.Suggest(textPage,new SuggestParams { PageName = "Nested Page", DocumentType = typeof(BasicMappedWebpage).FullName, UseHierarchy = true }); documentUrl.Should().Be("parent/test-page/nested-page-1"); }
public void Document_Grouping_CanGroupByDocumentType() { var document1 = new BasicMappedNoChildrenInNavWebpage(); var document2 = new BasicMappedNoChildrenInNavWebpage {PublishOn = DateTime.Today.AddDays(-1)}; var document3 = new BasicMappedWebpage(); Session.Transact(session => { session.Save(document1); session.Save(document2); session.Save(document3); }); Webpage webpageAlias = null; DocumentTypeCount countAlias = null; var list = Session.QueryOver(()=>webpageAlias) .SelectList( builder => builder.SelectGroup(() => webpageAlias.DocumentType) .WithAlias(() => countAlias.DocumentType) .SelectCount(() => webpageAlias.Id) .WithAlias(() => countAlias.Total) .SelectSubQuery(QueryOver.Of<Webpage>().Where(webpage => webpage.DocumentType == webpageAlias.DocumentType && (webpage.PublishOn == null || webpage.PublishOn > CurrentRequestData.Now)).ToRowCountQuery()) .WithAlias(() => countAlias.Unpublished)) .TransformUsing(Transformers.AliasToBean<DocumentTypeCount>()) .List<DocumentTypeCount>(); list.Should().HaveCount(2); list.Sum(count => count.Unpublished).Should().Be(2); }
public void DocumentService_SaveDocument_ReturnsTheSameDocument() { var document = new BasicMappedWebpage(); Session.Transact(session => session.Save(document)); BasicMappedWebpage updatedDocument = _documentService.SaveDocument(document); document.Should().BeSameAs(updatedDocument); }
public void DocumentService_GetDocumentByUrl_ReturnsTheDocumentWithTheSpecifiedUrl() { var textPage = new BasicMappedWebpage {UrlSegment = "test-page", Site = CurrentSite}; Session.Transact(session => session.SaveOrUpdate(textPage)); var document = _documentService.GetDocumentByUrl<BasicMappedWebpage>("test-page"); document.Should().NotBeNull(); }
public void AssignsAddedUrlHistoryToTheWebpage() { GetAllHistories().Should().HaveCount(0); var basicMappedWebpage = new BasicMappedWebpage(); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string> {"test"}}, basicMappedWebpage); GetAllHistories().ElementAt(0).Webpage.Should().Be(basicMappedWebpage); }
public void SiteSettingOptionGenerator_GetErrorPageOptions_ExcludesSavedUnpublishedWebpages() { var siteSettingsOptionGenerator = new SiteSettingsOptionGenerator(); var textPage = new BasicMappedWebpage { Name = "Test 1"}; Session.Transact(session => session.Save(textPage)); var errorPageOptions = siteSettingsOptionGenerator.GetErrorPageOptions(Session, -1); errorPageOptions.Should().HaveCount(0); }
public void SiteSettingsOptionGenerator_GetErrorPageOptions_ItemIsSelectedIfTheIdMatches() { var siteSettingsOptionGenerator = new SiteSettingsOptionGenerator(); var textPage = new BasicMappedWebpage { PublishOn = CurrentRequestData.Now.AddDays(-1), Name = "Test 1", Site = CurrentSite }; Session.Transact(session => session.Save(textPage)); var errorPageOptions = siteSettingsOptionGenerator.GetErrorPageOptions(Session, textPage.Id); errorPageOptions.Should().HaveCount(1); errorPageOptions[0].Selected.Should().BeTrue(); }
public void ShouldAssignWebpageToTag() { GetAllTags().Should().HaveCount(0); var webpage = new BasicMappedWebpage(); webpage.Tags.Should().HaveCount(0); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List<string> { "test" } }, webpage); webpage.Tags.ElementAt(0).Documents.Should().HaveCount(1); webpage.Tags.ElementAt(0).Documents.ElementAt(0).Should().Be(webpage); }
public void DocumentService_Unpublish_ShouldSetPublishOnToNull() { DateTime publishOn = CurrentRequestData.Now.AddDays(-1); var textPage = new BasicMappedWebpage { PublishOn = publishOn }; Session.Transact(session => session.Save(textPage)); _documentService.Unpublish(textPage); textPage.PublishOn.Should().NotHaveValue(); }
public void ShouldAssignTagToWebpage() { var webpage = new BasicMappedWebpage(); webpage.Tags.Should().HaveCount(0); A.CallTo(() => _getExistingTag.GetTag("test")).Returns(null); _sut.SetTags(_tags, webpage); webpage.Tags.Should().HaveCount(1); webpage.Tags.ElementAt(0).Name.Should().Be("test"); }
public void DocumentService_GetDocumentByUrl_ShouldReturnNullIfTheRequestedTypeDoesNotMatch() { var site = new Site(); var textPage = new BasicMappedWebpage { UrlSegment = "test-page", Site = site }; Session.Transact(session => session.SaveOrUpdate(textPage)); var document = _documentService.GetDocumentByUrl <Layout>("test-page"); document.Should().BeNull(); }
public void DocumentService_PublishNow_PublishedWebpageShouldNotChangeValue() { DateTime publishOn = CurrentRequestData.Now.AddDays(-1); var textPage = new BasicMappedWebpage { PublishOn = publishOn }; Session.Transact(session => session.Save(textPage)); _documentService.PublishNow(textPage); textPage.PublishOn.Should().Be(publishOn); }
public void SiteSettingsOptionGenerator_GetErrorPageOptions_IncludesSavedPublishedWebpages() { var siteSettingsOptionGenerator = new SiteSettingsOptionGenerator(); var textPage = new BasicMappedWebpage { PublishOn = CurrentRequestData.Now.AddDays(-1), Name = "Test 1", Site = CurrentSite }; Session.Transact(session => session.Save(textPage)); var errorPageOptions = siteSettingsOptionGenerator.GetErrorPageOptions(Session, -1); errorPageOptions.Should().HaveCount(1); errorPageOptions[0].Text.Should().Be("Test 1"); errorPageOptions[0].Value.Should().Be(textPage.Id.ToString()); }
public void UnAssigningAUrlHistoryShouldSetTheWebpageToNull() { var urlHistory = new UrlHistory {UrlSegment = "test"}; var basicMappedWebpage = new BasicMappedWebpage {Urls = new List<UrlHistory> {urlHistory}}; urlHistory.Webpage = basicMappedWebpage; Session.Transact(session => session.Save(urlHistory)); GetAllHistories().Should().HaveCount(1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string>()}, basicMappedWebpage); GetAllHistories().ElementAt(0).Webpage.Should().BeNull(); }
public void SiteSettingOptionGenerator_GetErrorPageOptions_ExcludesSavedUnpublishedWebpages() { var siteSettingsOptionGenerator = new SiteSettingsOptionGenerator(); var textPage = new BasicMappedWebpage { Name = "Test 1" }; Session.Transact(session => session.Save(textPage)); var errorPageOptions = siteSettingsOptionGenerator.GetErrorPageOptions(Session, -1); errorPageOptions.Should().HaveCount(0); }
public void AssignsAddedUrlHistoryToTheWebpage() { GetAllHistories().Should().HaveCount(0); var basicMappedWebpage = new BasicMappedWebpage(); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO { UrlHistory = new List <string> { "test" } }, basicMappedWebpage); GetAllHistories().ElementAt(0).Webpage.Should().Be(basicMappedWebpage); }
public void UnAssigningAUrlHistoryRemoveTheItemFromTheWebpageUrlList() { var urlHistory = new UrlHistory {UrlSegment = "test"}; var basicMappedWebpage = new BasicMappedWebpage {Urls = new List<UrlHistory> {urlHistory}}; urlHistory.Webpage = basicMappedWebpage; Session.Transact(session => session.Save(urlHistory)); basicMappedWebpage.Urls.Should().HaveCount(1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string>()}, basicMappedWebpage); basicMappedWebpage.Urls.Should().HaveCount(0); }
public void WebpageUrlGenerator_GetDocumentUrl_ReturnsAUrlBasedOnTheNameIfTheFlagIsSetToFalse() { var textPage = new BasicMappedWebpage { Name = "Test Page", UrlSegment = "test-page", Site = CurrentSite }; Session.Transact(session => session.SaveOrUpdate(textPage)); string documentUrl = _webpageUrlService.Suggest(textPage, new SuggestParams { PageName = "Nested Page", DocumentType = typeof(BasicMappedWebpage).FullName, UseHierarchy = false }); documentUrl.Should().Be("nested-page"); }
public void ShouldRemoveTagIfItIsNoLongerAssignedWebpage() { var tag = new Tag { Name = "Test" }; var webpage = new BasicMappedWebpage { Tags = new HashSet <Tag> { tag } }; _sut.SetTags(new List <string>(), webpage); webpage.Tags.Should().HaveCount(0); }
public void ShouldAssignWebpageToTag() { GetAllTags().Should().HaveCount(0); var webpage = new BasicMappedWebpage(); webpage.Tags.Should().HaveCount(0); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List <string> { "test" } }, webpage); webpage.Tags.ElementAt(0).Documents.Should().HaveCount(1); webpage.Tags.ElementAt(0).Documents.ElementAt(0).Should().Be(webpage); }
public void ShouldAssignExistingTagIfItIsADuplicate() { Session.Transact(session => session.Save(new Tag { Name = "Test" })); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage(); webpage.Tags.Should().HaveCount(0); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List <string> { "test" } }, webpage); webpage.Tags.Should().HaveCount(1); webpage.Tags.ElementAt(0).Name.Should().Be("Test"); }
public void ShouldRemoveTheWebpageFromTheTagsWebpages() { var tag = new Tag { Name = "Test" }; _tagRepository.Add(tag); var webpage = new BasicMappedWebpage { Tags = new HashSet <Tag> { tag } }; tag.Documents.Add(webpage); tag.Documents.Should().HaveCount(1); _sut.SetTags(new List <string>(), webpage); tag.Documents.Should().HaveCount(0); }
public void MovesTheUrlHistoryBetweenPagesIfTheyAreChanged() { var urlHistory = new UrlHistory {UrlSegment = "test"}; var basicMappedWebpage1 = new BasicMappedWebpage {Urls = new List<UrlHistory> {urlHistory}}; urlHistory.Webpage = basicMappedWebpage1; var basicMappedWebpage2 = new BasicMappedWebpage {Urls = new List<UrlHistory>()}; Session.Transact(session => session.Save(urlHistory)); Session.Transact(session => session.Save(basicMappedWebpage1)); Session.Transact(session => session.Save(basicMappedWebpage2)); basicMappedWebpage1.Urls.Should().HaveCount(1); basicMappedWebpage2.Urls.Should().HaveCount(0); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string>()}, basicMappedWebpage1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string> {"test"}}, basicMappedWebpage2); basicMappedWebpage1.Urls.Should().HaveCount(0); basicMappedWebpage2.Urls.Should().HaveCount(1); }
public void IfTagIsRemovedFromWebpageShouldNotRemoveTagFromList() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet <Tag> { tag } }; _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List <string> { } }, webpage); GetAllTags().Should().HaveCount(1); }
public void ShouldRemoveTagIfItIsNoLongerAssignedWebpage() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet <Tag> { tag } }; _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List <string> { } }, webpage); webpage.Tags.Should().HaveCount(0); }
public void UnAssigningAUrlHistoryRemoveTheItemFromTheWebpageUrlList() { var urlHistory = new UrlHistory { UrlSegment = "test" }; var basicMappedWebpage = new BasicMappedWebpage { Urls = new List <UrlHistory> { urlHistory } }; urlHistory.Webpage = basicMappedWebpage; Session.Transact(session => session.Save(urlHistory)); basicMappedWebpage.Urls.Should().HaveCount(1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO { UrlHistory = new List <string>() }, basicMappedWebpage); basicMappedWebpage.Urls.Should().HaveCount(0); }
public void UnAssigningAUrlHistoryShouldSetTheWebpageToNull() { var urlHistory = new UrlHistory { UrlSegment = "test" }; var basicMappedWebpage = new BasicMappedWebpage { Urls = new List <UrlHistory> { urlHistory } }; urlHistory.Webpage = basicMappedWebpage; Session.Transact(session => session.Save(urlHistory)); GetAllHistories().Should().HaveCount(1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO { UrlHistory = new List <string>() }, basicMappedWebpage); GetAllHistories().ElementAt(0).Webpage.Should().BeNull(); }
public void ShouldRemoveTheWebpageFromTheTagsWebpages() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet <Tag> { tag } }; tag.Documents.Add(webpage); tag.Documents.Should().HaveCount(1); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List <string>() }, webpage); tag.Documents.Should().HaveCount(0); }
public void MovesTheUrlHistoryBetweenPagesIfTheyAreChanged() { var urlHistory = new UrlHistory { UrlSegment = "test" }; var basicMappedWebpage1 = new BasicMappedWebpage { Urls = new List <UrlHistory> { urlHistory } }; urlHistory.Webpage = basicMappedWebpage1; var basicMappedWebpage2 = new BasicMappedWebpage { Urls = new List <UrlHistory>() }; Session.Transact(session => session.Save(urlHistory)); Session.Transact(session => session.Save(basicMappedWebpage1)); Session.Transact(session => session.Save(basicMappedWebpage2)); basicMappedWebpage1.Urls.Should().HaveCount(1); basicMappedWebpage2.Urls.Should().HaveCount(0); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO { UrlHistory = new List <string>() }, basicMappedWebpage1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO { UrlHistory = new List <string> { "test" } }, basicMappedWebpage2); basicMappedWebpage1.Urls.Should().HaveCount(0); basicMappedWebpage2.Urls.Should().HaveCount(1); }
public void IfTagIsRemovedFromWebpageShouldNotRemoveTagFromList() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet<Tag> { tag } }; _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List<string> { } }, webpage); GetAllTags().Should().HaveCount(1); }
public void ShouldRemoveTagIfItIsNoLongerAssignedWebpage() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet<Tag> { tag } }; _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List<string> { } }, webpage); webpage.Tags.Should().HaveCount(0); }
public void ShouldAssignExistingTagIfItIsADuplicate() { Session.Transact(session => session.Save(new Tag { Name = "Test" })); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage(); webpage.Tags.Should().HaveCount(0); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List<string> { "test" } }, webpage); webpage.Tags.Should().HaveCount(1); webpage.Tags.ElementAt(0).Name.Should().Be("Test"); }
public void DocumentService_PublishNow_UnpublishedWebpageWillGetPublishedOnValue() { var textPage = new BasicMappedWebpage(); Session.Transact(session => session.Save(textPage)); _documentService.PublishNow(textPage); textPage.PublishOn.Should().HaveValue(); }
public void DocumentService_PublishNow_PublishedWebpageShouldNotChangeValue() { DateTime publishOn = CurrentRequestData.Now.AddDays(-1); var textPage = new BasicMappedWebpage {PublishOn = publishOn}; Session.Transact(session => session.Save(textPage)); _documentService.PublishNow(textPage); textPage.PublishOn.Should().Be(publishOn); }
public void ShouldRemoveTheWebpageFromTheTagsWebpages() { var tag = new Tag { Name = "Test" }; Session.Transact(session => session.Save(tag)); GetAllTags().Should().HaveCount(1); var webpage = new BasicMappedWebpage { Tags = new HashSet<Tag> { tag } }; tag.Documents.Add(webpage); tag.Documents.Should().HaveCount(1); _updateTagsService.SetTags(new DocumentImportDTO { Tags = new List<string>() }, webpage); tag.Documents.Should().HaveCount(0); }
public void DocumentService_Unpublish_ShouldSetPublishOnToNull() { DateTime publishOn = CurrentRequestData.Now.AddDays(-1); var textPage = new BasicMappedWebpage {PublishOn = publishOn}; Session.Transact(session => session.Save(textPage)); _documentService.Unpublish(textPage); textPage.PublishOn.Should().NotHaveValue(); }
public void DocumentService_DeleteDocument_ShouldCallSessionDelete() { var textPage = new BasicMappedWebpage(); Session.Transact(session => session.Save(textPage)); _documentService.DeleteDocument(textPage); Session.QueryOver<Webpage>().RowCount().Should().Be(0); }
public void DocumentService_GetDocumentByUrl_ShouldReturnNullIfTheRequestedTypeDoesNotMatch() { var site = new Site(); var textPage = new BasicMappedWebpage {UrlSegment = "test-page", Site = site}; Session.Transact(session => session.SaveOrUpdate(textPage)); var document = _documentService.GetDocumentByUrl<Layout>("test-page"); document.Should().BeNull(); }
public void ShouldNotCreateNewUrlHistoryWhileMovingUrls() { var urlHistory = new UrlHistory {UrlSegment = "test"}; var basicMappedWebpage1 = new BasicMappedWebpage {Urls = new List<UrlHistory> {urlHistory}}; urlHistory.Webpage = basicMappedWebpage1; var basicMappedWebpage2 = new BasicMappedWebpage {Urls = new List<UrlHistory>()}; Session.Transact(session => session.Save(urlHistory)); Session.Transact(session => session.Save(basicMappedWebpage1)); Session.Transact(session => session.Save(basicMappedWebpage2)); GetAllHistories().Should().HaveCount(1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string>()}, basicMappedWebpage1); _updateUrlHistoryService.SetUrlHistory(new DocumentImportDTO {UrlHistory = new List<string> {"test"}}, basicMappedWebpage2); GetAllHistories().Should().HaveCount(1); }