internal static async Task <ContentItemModel> PrepareTestItem(ManagementClient client, string typeCodename, string externalId = null) { var type = ContentTypeIdentifier.ByCodename(typeCodename); if (externalId != null) { // We use upsert for preparing item by external ID in order to be able to recover from situation when previous test run didn't clean up properly var item = new ContentItemUpsertModel() { Name = "Hooray!", Type = type, }; return(await client.UpsertContentItemByExternalIdAsync(externalId, item)); } else { var item = new ContentItemCreateModel() { Name = "Hooray!", Type = type, }; return(await client.CreateContentItemAsync(item)); } }