public async Task SaveGetContent() { var repository = new SiteRepository(SessionFactory, new ContentServiceFactory(_contentFactory)); var internalId = Guid.NewGuid().ToString("N"); var site = new Site { Description = $"Site description {internalId}", InternalId = internalId, Title = $"Title {internalId}", IsDefault = true, SiteTypeId = "MySiteContent" }; var content = new MySiteContent { Header = "<p>Lorem ipsum</p>", Footer = "<p>Tellus Ligula</p>" }; await repository.Save(site).ConfigureAwait(false); var siteId = site.Id; await repository.SaveContent(siteId, content).ConfigureAwait(false); var contentId = content.Id; var retrieved = await repository.GetContentById <MySiteContent>(contentId).ConfigureAwait(false); Assert.AreNotEqual(Guid.Empty, retrieved.Id); Assert.AreEqual(content.Header, retrieved.Header); Assert.AreEqual(content.Footer, retrieved.Footer); }
public async Task SaveContent_PublishedOnly() { var repository = new SiteRepository(SessionFactory, new ContentServiceFactory(_contentFactory)); var internalId = Guid.NewGuid().ToString("N"); var siteId = await MakeSite().ConfigureAwait(false); var ex = Assert.ThrowsAsync <ArgumentNullException>(async() => await repository.SaveContent <MySiteContent>(siteId, null).ConfigureAwait(false)); Assert.AreEqual("Parameter 'content' cannot be null. [Location 201226-2334] (Parameter 'content')", ex.Message); }
public async Task SaveContent_CanHandleContentNull() { var repository = new SiteRepository(SessionFactory, new ContentServiceFactory(_contentFactory)); var internalId = Guid.NewGuid().ToString("N"); var site = new Site { Description = $"Site description {internalId}", InternalId = internalId, Title = $"Title {internalId}", IsDefault = true, SiteTypeId = "MySiteContent" }; await repository.Save(site).ConfigureAwait(false); var siteId = site.Id; var ex = Assert.ThrowsAsync <ArgumentNullException>(async() => await repository.SaveContent <MySiteContent>(siteId, null).ConfigureAwait(false)); Assert.AreEqual("Parameter 'content' cannot be null. [Location 201226-2334] (Parameter 'content')", ex.Message); }