public override async Task InitializeAsync() { _services = new ServiceCollection() .AddSingleton <IMyService, MyService>() .BuildServiceProvider(); using (var api = CreateApi()) { Piranha.App.Init(api); Piranha.App.Fields.Register <MyFourthField>(); var pageTypeBuilder = new PageTypeBuilder(api) .AddType(typeof(BlogPage)); pageTypeBuilder.Build(); var postTypeBuilder = new PostTypeBuilder(api) .AddType(typeof(MissingPost)) .AddType(typeof(MyPost)) .AddType(typeof(MyCollectionPost)) .AddType(typeof(MyDIPost)); postTypeBuilder.Build(); // Add site var site = new Site { Id = SITE_ID, Title = "Post Site", InternalId = "PostSite", IsDefault = true }; await api.Sites.SaveAsync(site); // Add blog page var page = await BlogPage.CreateAsync(api); page.Id = BLOG_ID; page.SiteId = SITE_ID; page.Title = "Blog"; await api.Pages.SaveAsync(page); var category = new Models.Taxonomy { Id = CAT_1_ID, Title = "My category" }; var post1 = await MyPost.CreateAsync(api); post1.Id = POST_1_ID; post1.BlogId = BLOG_ID; post1.Category = category; post1.Title = "My first post"; post1.Ingress = "My first ingress"; post1.Body = "My first body"; post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Sollicitudin Aenean" }); post1.Blocks.Add(new Extend.Blocks.TextBlock { Body = "Ipsum Elit" }); await api.Posts.SaveAsync(post1); var post2 = await MyPost.CreateAsync(api); post2.Id = POST_2_ID; post2.BlogId = BLOG_ID; post2.Category = category; post2.Title = "My second post"; post2.Ingress = "My second ingress"; post2.Body = "My second body"; await api.Posts.SaveAsync(post2); var post3 = await MyPost.CreateAsync(api); post3.Id = POST_3_ID; post3.BlogId = BLOG_ID; post3.Category = category; post3.Title = "My third post"; post3.Ingress = "My third ingress"; post3.Body = "My third body"; await api.Posts.SaveAsync(post3); var post4 = await MyCollectionPost.CreateAsync(api); post4.BlogId = BLOG_ID; post4.Category = category; post4.Title = "My collection post"; post4.Texts.Add(new TextField { Value = "First text" }); post4.Texts.Add(new TextField { Value = "Second text" }); post4.Texts.Add(new TextField { Value = "Third text" }); await api.Posts.SaveAsync(post4); var post6 = await MyDIPost.CreateAsync(api); post6.Id = POST_DI_ID; post6.BlogId = BLOG_ID; post6.Category = category; post6.Title = "My Injection Post"; await api.Posts.SaveAsync(post6); } }