Files
Umbraco-CMS/src/Umbraco.Tests/Services/TestWithSomeContentBase.cs
2018-04-03 14:54:01 +02:00

51 lines
2.2 KiB
C#

using System;
using System.Threading;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
namespace Umbraco.Tests.Services
{
[TestFixture]
[Apartment(ApartmentState.STA)]
public abstract class TestWithSomeContentBase : TestWithDatabaseBase
{
public override void SetUp()
{
base.SetUp();
CreateTestData();
}
public virtual void CreateTestData()
{
//NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
//Create and Save ContentType "umbTextpage" -> 1060
ContentType contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage", "Textpage");
contentType.Key = new Guid("1D3A8E6E-2EA9-4CC1-B229-1AEE19821522");
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType!
ServiceContext.ContentTypeService.Save(contentType);
//Create and Save Content "Homepage" based on "umbTextpage" -> 1061
Content textpage = MockedContent.CreateSimpleContent(contentType);
textpage.Key = new Guid("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0");
ServiceContext.ContentService.Save(textpage, 0);
//Create and Save Content "Text Page 1" based on "umbTextpage" -> 1062
Content subpage = MockedContent.CreateSimpleContent(contentType, "Text Page 1", textpage.Id);
subpage.ReleaseDate = DateTime.Now.AddMinutes(-5);
ServiceContext.ContentService.Save(subpage, 0);
//Create and Save Content "Text Page 1" based on "umbTextpage" -> 1063
Content subpage2 = MockedContent.CreateSimpleContent(contentType, "Text Page 2", textpage.Id);
ServiceContext.ContentService.Save(subpage2, 0);
//Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1064
Content trashed = MockedContent.CreateSimpleContent(contentType, "Text Page Deleted", -20);
trashed.Trashed = true;
ServiceContext.ContentService.Save(trashed, 0);
}
}
}