mirror of https://github.com/Squidex/squidex.git
20 changed files with 292 additions and 103 deletions
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Squidex.Domain.Apps.Write.Schemas |
|||
{ |
|||
public class SchemaEvents |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// ==========================================================================
|
|||
// IMigratedEvent.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Infrastructure.CQRS.Events |
|||
{ |
|||
public interface IMigratedEvent |
|||
{ |
|||
IEvent Migrate(); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
// ==========================================================================
|
|||
// NoopEvent.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
namespace Squidex.Infrastructure.CQRS.Events |
|||
{ |
|||
public sealed class NoopEvent : IEvent |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
// ==========================================================================
|
|||
// SchemaEventTests.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using Squidex.Domain.Apps.Core.Contents; |
|||
using Squidex.Domain.Apps.Events.Contents; |
|||
using Squidex.Domain.Apps.Events.Contents.Old; |
|||
using Squidex.Domain.Apps.Write.TestHelpers; |
|||
using Squidex.Infrastructure; |
|||
using Xunit; |
|||
|
|||
#pragma warning disable CS0612 // Type or member is obsolete
|
|||
|
|||
namespace Squidex.Domain.Apps.Write.Contents |
|||
{ |
|||
public class ContentEventTests |
|||
{ |
|||
private readonly RefToken actor = new RefToken("User", Guid.NewGuid().ToString()); |
|||
private readonly NamedId<Guid> appId = new NamedId<Guid>(Guid.NewGuid(), "my-app"); |
|||
private readonly NamedId<Guid> schemaId = new NamedId<Guid>(Guid.NewGuid(), "my-schema"); |
|||
private readonly Guid contentId = Guid.NewGuid(); |
|||
|
|||
[Fact] |
|||
public void Should_migrate_content_published_to_content_status_changed() |
|||
{ |
|||
var source = CreateEvent(new ContentPublished()); |
|||
|
|||
source.Migrate().ShouldBeSameEvent(CreateEvent(new ContentStatusChanged { Status = Status.Published })); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_migrate_content_unpublished_to_content_status_changed() |
|||
{ |
|||
var source = CreateEvent(new ContentUnpublished()); |
|||
|
|||
source.Migrate().ShouldBeSameEvent(CreateEvent(new ContentStatusChanged { Status = Status.Draft })); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_migrate_content_restored_to_content_status_changed() |
|||
{ |
|||
var source = CreateEvent(new ContentRestored()); |
|||
|
|||
source.Migrate().ShouldBeSameEvent(CreateEvent(new ContentStatusChanged { Status = Status.Draft })); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_migrate_content_archived_to_content_status_changed() |
|||
{ |
|||
var source = CreateEvent(new ContentArchived()); |
|||
|
|||
source.Migrate().ShouldBeSameEvent(CreateEvent(new ContentStatusChanged { Status = Status.Archived })); |
|||
} |
|||
|
|||
private T CreateEvent<T>(T contentEvent) where T : ContentEvent |
|||
{ |
|||
contentEvent.Actor = actor; |
|||
contentEvent.AppId = appId; |
|||
contentEvent.SchemaId = schemaId; |
|||
contentEvent.ContentId = contentId; |
|||
|
|||
return contentEvent; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
// ==========================================================================
|
|||
// SchemaEventTests.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Domain.Apps.Events.Schemas.Old; |
|||
using Squidex.Domain.Apps.Write.TestHelpers; |
|||
using Squidex.Infrastructure.CQRS.Events; |
|||
using Xunit; |
|||
|
|||
#pragma warning disable CS0612 // Type or member is obsolete
|
|||
|
|||
namespace Squidex.Domain.Apps.Write.Schemas |
|||
{ |
|||
public class SchemaEventTests |
|||
{ |
|||
[Fact] |
|||
public void Should_migrate_webhook_added_event_to_noop() |
|||
{ |
|||
var source = new WebhookAdded(); |
|||
|
|||
source.Migrate().ShouldBeSameEventType(new NoopEvent()); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_migrate_webhook_deleted_event_to_noop() |
|||
{ |
|||
var source = new WebhookDeleted(); |
|||
|
|||
source.Migrate().ShouldBeSameEventType(new NoopEvent()); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue