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.
43 lines
1.3 KiB
43 lines
1.3 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Squidex.Infrastructure.Commands;
|
|
using Squidex.Infrastructure.EventSourcing;
|
|
|
|
namespace Squidex.Infrastructure.TestHelpers
|
|
{
|
|
public sealed record MyDomainState : IDomainState<MyDomainState>
|
|
{
|
|
public const long Unchanged = 13;
|
|
|
|
public bool IsDeleted { get; set; }
|
|
|
|
public long Value { get; set; }
|
|
|
|
public MyDomainState Apply(Envelope<IEvent> @event)
|
|
{
|
|
switch (@event.Payload)
|
|
{
|
|
case ValueChanged valueChanged when (valueChanged.Value != Unchanged):
|
|
return this with { Value = valueChanged.Value };
|
|
case Deleted when (!IsDeleted):
|
|
return this with { IsDeleted = true };
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public sealed class ValueChanged : IEvent
|
|
{
|
|
public long Value { get; set; }
|
|
}
|
|
|
|
public sealed class Deleted : IEvent
|
|
{
|
|
}
|
|
}
|
|
|