Headless CMS and Content Managment Hub
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.5 KiB

// ==========================================================================
// EnrichWithTimestampHandlerTests.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Threading.Tasks;
using Xunit;
namespace Squidex.Infrastructure.CQRS.Commands
{
public sealed class EnrichWithTimestampHandlerTests
{
private sealed class NormalCommand : AggregateCommand
{
}
private sealed class TimestampCommand : AggregateCommand, ITimestampCommand
{
public DateTime Timestamp { get; set; }
}
[Fact]
public async Task Should_set_timestamp_when_is_timestamp_command()
{
var utc = DateTime.Today;
var sut = new EnrichWithTimestampHandler(() => utc);
var command = new TimestampCommand();
var result = await sut.HandleAsync(new CommandContext(command));
Assert.False(result);
Assert.Equal(utc, command.Timestamp);
}
[Fact]
public async Task Should_do_nothing_for_normal_command()
{
var utc = DateTime.Today;
var sut = new EnrichWithTimestampHandler(() => utc);
var result = await sut.HandleAsync(new CommandContext(new NormalCommand()));
Assert.False(result);
}
}
}