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.
51 lines
1.7 KiB
51 lines
1.7 KiB
// ==========================================================================
|
|
// AppEventTests.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using Squidex.Domain.Apps.Core.Apps;
|
|
using Squidex.Domain.Apps.Entities.TestHelpers;
|
|
using Squidex.Domain.Apps.Events;
|
|
using Squidex.Domain.Apps.Events.Apps;
|
|
using Squidex.Domain.Apps.Events.Apps.Old;
|
|
using Squidex.Infrastructure;
|
|
using Xunit;
|
|
|
|
#pragma warning disable CS0612 // Type or member is obsolete
|
|
|
|
namespace Squidex.Domain.Apps.Entities.Apps
|
|
{
|
|
public class AppEventTests
|
|
{
|
|
private readonly RefToken actor = new RefToken("User", Guid.NewGuid().ToString());
|
|
private readonly NamedId<Guid> appId = new NamedId<Guid>(Guid.NewGuid(), "my-app");
|
|
|
|
[Fact]
|
|
public void Should_migrate_client_changed_as_reader_to_client_updated()
|
|
{
|
|
var source = CreateEvent(new AppClientChanged { IsReader = true });
|
|
|
|
source.Migrate().ShouldBeSameEvent(CreateEvent(new AppClientUpdated { Permission = AppClientPermission.Reader }));
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_migrate_client_changed_as_writer_to_client_updated()
|
|
{
|
|
var source = CreateEvent(new AppClientChanged { IsReader = false });
|
|
|
|
source.Migrate().ShouldBeSameEvent(CreateEvent(new AppClientUpdated { Permission = AppClientPermission.Editor }));
|
|
}
|
|
|
|
private T CreateEvent<T>(T contentEvent) where T : AppEvent
|
|
{
|
|
contentEvent.Actor = actor;
|
|
contentEvent.AppId = appId;
|
|
|
|
return contentEvent;
|
|
}
|
|
}
|
|
}
|
|
|