adds unit tests for File service for templates
This commit is contained in:
72
src/Umbraco.Tests/Services/FileServiceTests.cs
Normal file
72
src/Umbraco.Tests/Services/FileServiceTests.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
[DatabaseTestBehavior(DatabaseBehavior.NewDbFileAndSchemaPerTest)]
|
||||
[TestFixture, RequiresSTA]
|
||||
public class FileServiceTests : BaseServiceTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_Template_Then_Assign_Child()
|
||||
{
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("child", "test");
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
|
||||
child.SetMasterTemplate(parent);
|
||||
ServiceContext.FileService.SaveTemplate(child);
|
||||
|
||||
child = ServiceContext.FileService.GetTemplate(child.Id);
|
||||
|
||||
Assert.AreEqual(parent.Alias, child.MasterTemplateAlias);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_Template_With_Child_Then_Unassign()
|
||||
{
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
var child = ServiceContext.FileService.CreateTemplateWithIdentity("child", "test", parent);
|
||||
|
||||
child.SetMasterTemplate(null);
|
||||
ServiceContext.FileService.SaveTemplate(child);
|
||||
|
||||
child = ServiceContext.FileService.GetTemplate(child.Id);
|
||||
|
||||
Assert.AreEqual(null, child.MasterTemplateAlias);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Query_Template_Children()
|
||||
{
|
||||
var parent = ServiceContext.FileService.CreateTemplateWithIdentity("parent", "test");
|
||||
var child1 = ServiceContext.FileService.CreateTemplateWithIdentity("child1", "test", parent);
|
||||
var child2 = ServiceContext.FileService.CreateTemplateWithIdentity("child2", "test", parent);
|
||||
|
||||
var children = ServiceContext.FileService.GetTemplates(parent.Id).Select(x => x.Id).ToArray();
|
||||
|
||||
Assert.IsTrue(children.Contains(child1.Id));
|
||||
Assert.IsTrue(children.Contains(child2.Id));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -322,6 +322,7 @@
|
||||
<Compile Include="PublishedContent\StronglyTypedModels\UmbracoTemplatePage`T.cs" />
|
||||
<Compile Include="Scheduling\BackgroundTaskRunnerTests.cs" />
|
||||
<Compile Include="ServerEnvironmentHelperTests.cs" />
|
||||
<Compile Include="Services\FileServiceTests.cs" />
|
||||
<Compile Include="Services\LocalizedTextServiceTests.cs" />
|
||||
<Compile Include="Services\TagServiceTests.cs" />
|
||||
<Compile Include="Services\LocalizationServiceTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user