public async Task Should_do_nothing_for_normal_command()
        {
            var sut = new EnrichWithTimestampHandler(clock);

            await sut.HandleAsync(new CommandContext(A.Dummy <ICommand>()));

            A.CallTo(() => clock.GetCurrentInstant()).MustNotHaveHappened();
        }
예제 #2
0
        public async Task Should_do_nothing_for_normal_command()
        {
            var sut = new EnrichWithTimestampHandler(clock.Object);

            var result = await sut.HandleAsync(new CommandContext(new Mock <ICommand>().Object));

            Assert.False(result);

            clock.Verify(x => x.GetCurrentInstant(), Times.Never());
        }
예제 #3
0
        public async Task Should_set_timestamp_for_timestamp_command()
        {
            var utc = Instant.FromUnixTimeSeconds(1000);
            var sut = new EnrichWithTimestampHandler(clock.Object);

            clock.Setup(x => x.GetCurrentInstant()).Returns(utc);

            var command = new MyTimestampCommand();

            var result = await sut.HandleAsync(new CommandContext(command));

            Assert.False(result);
            Assert.Equal(utc, command.Timestamp);
        }
        public async Task Should_set_timestamp_for_timestamp_command()
        {
            var utc = Instant.FromUnixTimeSeconds(1000);
            var sut = new EnrichWithTimestampHandler(clock);

            A.CallTo(() => clock.GetCurrentInstant())
            .Returns(utc);

            var command = new MyTimestampCommand();

            await sut.HandleAsync(new CommandContext(command));

            Assert.Equal(utc, command.Timestamp);
        }