mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.7 KiB
93 lines
2.7 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using Squidex.Domain.Apps.Core.Contents;
|
|
using Xunit;
|
|
|
|
#pragma warning disable SA1310 // Field names must not contain underscore
|
|
|
|
namespace Squidex.Domain.Apps.Core.Model.Contents
|
|
{
|
|
public class WorkflowsTests
|
|
{
|
|
private readonly Workflows workflows_0 = Workflows.Empty;
|
|
|
|
[Fact]
|
|
public void Should_provide_default_workflow_if_none_found()
|
|
{
|
|
var workflow = workflows_0.GetFirst();
|
|
|
|
Assert.Same(Workflow.Default, workflow);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_set_workflow_with_empty_guid()
|
|
{
|
|
var workflows_1 = workflows_0.Set(Workflow.Default);
|
|
|
|
Assert.Single(workflows_1);
|
|
Assert.Same(Workflow.Default, workflows_1[Guid.Empty]);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_add_new_workflow_with_default_states()
|
|
{
|
|
var id = Guid.NewGuid();
|
|
|
|
var workflows_1 = workflows_0.Add(id, "1");
|
|
|
|
Assert.Equal(workflows_1[id].Steps.Keys, new[] { Status.Archived, Status.Draft, Status.Published });
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_update_workflow()
|
|
{
|
|
var id = Guid.NewGuid();
|
|
|
|
var workflows_1 = workflows_0.Add(id, "1");
|
|
var workflows_2 = workflows_1.Update(id, Workflow.Empty);
|
|
|
|
Assert.Empty(workflows_2.GetFirst().Steps.Keys);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_update_workflow_with_default_guid()
|
|
{
|
|
var workflows_1 = workflows_0.Update(Guid.Empty, Workflow.Empty);
|
|
|
|
Assert.NotEmpty(workflows_1);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_do_nothing_if_workflow_to_update_not_found()
|
|
{
|
|
var workflows_1 = workflows_0.Update(Guid.NewGuid(), Workflow.Empty);
|
|
|
|
Assert.Same(workflows_0, workflows_1);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_remove_workflow()
|
|
{
|
|
var id = Guid.NewGuid();
|
|
|
|
var workflows_1 = workflows_0.Add(id, "1");
|
|
var workflows_2 = workflows_1.Remove(id);
|
|
|
|
Assert.Empty(workflows_2);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_do_nothing_if_workflow_to_remove_not_found()
|
|
{
|
|
var workflows_1 = workflows_0.Remove(Guid.NewGuid());
|
|
|
|
Assert.Empty(workflows_1);
|
|
}
|
|
}
|
|
}
|
|
|