-
Notifications
You must be signed in to change notification settings - Fork 9
/
Creating_Content.cs
58 lines (47 loc) · 1.8 KB
/
Creating_Content.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Builders.Extensions;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
namespace Our.Umbraco.Test.Examples.Content;
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class Creating_Content : UmbracoIntegrationTest
{
[Test]
public void Makes_Empty_Properties()
{
var contentService = GetRequiredService<IContentService>();
var empty = contentService.Create("An empty one", -1, contentType, -1);
Assert.That(empty.Properties, Has.One.With.Property(nameof(IProperty.Alias)).EqualTo("aTextBox"));
}
private IContentType? contentType;
[SetUp]
public void SetupSchema()
{
if (contentType != null) return;
var contentTypeService = GetRequiredService<IContentTypeService>();
var compositionType = new ContentTypeBuilder()
.WithAlias("aComposition")
.WithName("A composition type")
.AddPropertyType()
.WithAlias("aTextBox")
.WithName("A composed textbox")
.WithDataTypeId(Constants.DataTypes.Textbox)
.Done()
.Build();
contentTypeService.Save(compositionType);
contentType = new ContentTypeBuilder()
.WithAlias("aContentType")
.WithName("A content type")
.AddPropertyType()
.WithAlias("anRte")
.WithName("An RTE")
.WithDataTypeId(Constants.DataTypes.RichtextEditor)
.Done()
.Build();
contentType.AddContentType(compositionType);
contentTypeService.Save(contentType);
}
}