public void EmptyCollectionPage() { using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { var page = MyCollectionPage.Create(api); Assert.Equal(0, page.Texts.Count); page.SiteId = SITE_ID; page.Title = "Another collection page"; api.Pages.Save(page); page = api.Pages.GetBySlug <MyCollectionPage>(Piranha.Utils.GenerateSlug(page.Title), SITE_ID); Assert.Equal(0, page.Texts.Count); } }
public void EmptyCollectionPageComplex() { using (var api = new Api(GetDb(), storage, cache)) { var page = MyCollectionPage.Create(api); Assert.Equal(0, page.Teasers.Count); page.SiteId = SITE_ID; page.Title = "Fourth collection page"; api.Pages.Save(page); page = api.Pages.GetBySlug <MyCollectionPage>(Piranha.Utils.GenerateSlug(page.Title), SITE_ID); Assert.Equal(0, page.Teasers.Count); } }
public void EmptyCollectionPage() { using (var api = CreateApi()) { var page = MyCollectionPage.Create(api); Assert.Equal(0, page.Texts.Count); page.SiteId = SITE_ID; page.Title = "Another collection page"; api.Pages.Save(page); page = api.Pages.GetBySlug <MyCollectionPage>(Piranha.Utils.GenerateSlug(page.Title), SITE_ID); Assert.Equal(0, page.Texts.Count); } }
public async Task EmptyCollectionPageComplex() { using (var api = CreateApi()) { var page = await MyCollectionPage.CreateAsync(api); Assert.Equal(0, page.Teasers.Count); page.SiteId = SITE_ID; page.Title = "Fourth collection page"; await api.Pages.SaveAsync(page); page = await api.Pages.GetBySlugAsync <MyCollectionPage>(Piranha.Utils.GenerateSlug(page.Title), SITE_ID); Assert.Equal(0, page.Teasers.Count); } }
protected override void Init() { using (var api = new Api(GetDb(), storage, cache)) { Piranha.App.Init(api); var builder = new PageTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)); builder.Build(); var site = new Data.Site() { Id = SITE_ID, Title = "Default Site", InternalId = "DefaultSite", IsDefault = true }; var emptysite = new Data.Site() { Id = SITE_ID, Title = "Empty Site", InternalId = "EmptySite", IsDefault = false }; api.Sites.Save(site); api.Sites.Save(emptysite); var page1 = MyPage.Create(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.Ingress = "My second ingress"; page2.Body = "My second body"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; api.Pages.Save(page3); var page4 = MyCollectionPage.Create(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField() { Value = "First text" }); page4.Texts.Add(new TextField() { Value = "Second text" }); page4.Texts.Add(new TextField() { Value = "Third text" }); api.Pages.Save(page4); var page5 = MyBlogPage.Create(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; api.Pages.Save(page5); } }
protected override void Init() { services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage, cache)) { Piranha.App.Init(); Piranha.App.Fields.Register <MyFourthField>(); var builder = new PageTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)) .AddType(typeof(MyDIPage)); builder.Build(); var site = new Data.Site { Id = SITE_ID, Title = "Default Site", InternalId = "DefaultSite", IsDefault = true }; var emptysite = new Data.Site { Id = SITE_ID, Title = "Empty Site", InternalId = "EmptySite", IsDefault = false }; api.Sites.Save(site); api.Sites.Save(emptysite); var page1 = MyPage.Create(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); api.Pages.Save(page1); var page2 = MyPage.Create(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.Ingress = "My second ingress"; page2.Body = "My second body"; api.Pages.Save(page2); var page3 = MyPage.Create(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; api.Pages.Save(page3); var page4 = MyCollectionPage.Create(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField { Value = "First text" }); page4.Texts.Add(new TextField { Value = "Second text" }); page4.Texts.Add(new TextField { Value = "Third text" }); api.Pages.Save(page4); var page5 = MyBlogPage.Create(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; api.Pages.Save(page5); var page6 = MyDIPage.Create(api); page6.Id = PAGE_DI_ID; page6.SiteId = SITE_ID; page6.Title = "My Injection Page"; api.Pages.Save(page6); var page7 = MyPage.Create(api); page7.Id = PAGE_7_ID; page7.SiteId = SITE_ID; page7.Title = "My base page"; page7.Ingress = "My base ingress"; page7.Body = "My base body"; page7.ParentId = PAGE_1_ID; page7.SortOrder = 1; api.Pages.Save(page7); var page8 = MyPage.Create(api); page8.OriginalPageId = PAGE_7_ID; page8.Id = PAGE_8_ID; page8.SiteId = SITE_ID; page8.Title = "My copied page"; page8.ParentId = PAGE_1_ID; page8.SortOrder = 2; page8.IsHidden = true; page8.Route = "test-route"; api.Pages.Save(page8); } }
public override async Task InitializeAsync() { _services = CreateServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = CreateApi()) { Piranha.App.Init(api); Piranha.App.Fields.Register <MyFourthField>(); new ContentTypeBuilder(api) .AddType(typeof(MissingPage)) .AddType(typeof(MyBlogPage)) .AddType(typeof(MyPage)) .AddType(typeof(MyCollectionPage)) .AddType(typeof(MyDIPage)) .Build(); var site = new Site { Id = SITE_ID, Title = "My Test Site", InternalId = "MyTestSite", IsDefault = true }; await api.Sites.SaveAsync(site); var page1 = await MyPage.CreateAsync(api); page1.Id = PAGE_1_ID; page1.SiteId = SITE_ID; page1.Title = "My first page"; page1.MetaKeywords = "Keywords"; page1.MetaDescription = "Description"; page1.OgTitle = "Og Title"; page1.OgDescription = "Og Description"; page1.Ingress = "My first ingress"; page1.Body = "My first body"; page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); page1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); page1.Published = DateTime.Now; await api.Pages.SaveAsync(page1); var page2 = await MyPage.CreateAsync(api); page2.Id = PAGE_2_ID; page2.SiteId = SITE_ID; page2.Title = "My second page"; page2.MetaFollow = false; page2.MetaIndex = false; page2.Ingress = "My second ingress"; page2.Body = "My second body"; await api.Pages.SaveAsync(page2); var page3 = await MyPage.CreateAsync(api); page3.Id = PAGE_3_ID; page3.SiteId = SITE_ID; page3.Title = "My third page"; page3.Ingress = "My third ingress"; page3.Body = "My third body"; await api.Pages.SaveAsync(page3); var page4 = await MyCollectionPage.CreateAsync(api); page4.SiteId = SITE_ID; page4.Title = "My collection page"; page4.SortOrder = 1; page4.Texts.Add(new TextField { Value = "First text" }); page4.Texts.Add(new TextField { Value = "Second text" }); page4.Texts.Add(new TextField { Value = "Third text" }); await api.Pages.SaveAsync(page4); var page5 = await MyBlogPage.CreateAsync(api); page5.SiteId = SITE_ID; page5.Title = "Blog Archive"; await api.Pages.SaveAsync(page5); var page6 = await MyDIPage.CreateAsync(api); page6.Id = PAGE_DI_ID; page6.SiteId = SITE_ID; page6.Title = "My Injection Page"; await api.Pages.SaveAsync(page6); var page7 = await MyPage.CreateAsync(api); page7.Id = PAGE_7_ID; page7.SiteId = SITE_ID; page7.Title = "My base page"; page7.Ingress = "My base ingress"; page7.Body = "My base body"; page7.ParentId = PAGE_1_ID; page7.SortOrder = 1; await api.Pages.SaveAsync(page7); var page8 = await MyPage.CreateAsync(api); page8.OriginalPageId = PAGE_7_ID; page8.Id = PAGE_8_ID; page8.SiteId = SITE_ID; page8.Title = "My copied page"; page8.ParentId = PAGE_1_ID; page8.SortOrder = 2; page8.IsHidden = true; page8.Route = "test-route"; await api.Pages.SaveAsync(page8); } }