public void CommandExecutionThrowsValidationExceptionWhenInvalid()
    {
        var command = new StartAndEndDateCommand
        {
            Start = DateTime.Now,
            End   = DateTime.Now.AddHours(-1)
        };

        Assert.ThrowsAsync <ValidationException>(async() => await this.requestProcessor.HandleAsync(command, default));
    }
    public async Task CommandExecutionSucceedsWhenValid()
    {
        var command = new StartAndEndDateCommand
        {
            Start = DateTime.Now,
            End   = DateTime.Now.AddHours(1)
        };

        await this.requestProcessor.HandleAsync(command, default);

        Assert.IsTrue(command.CommandExecuted);
    }
    public void CommandValidationFailsWhenEndIsBeforeStart()
    {
        var command = new StartAndEndDateCommand
        {
            Start = DateTime.Now,
            End   = DateTime.Now.AddHours(-1)
        };

        var validators = this.GetAllValidators <StartAndEndDateCommand>();
        var isValid    = validators.All(v => v.Validate(command).IsValid);

        Assert.IsFalse(isValid);
    }
    public void CommandValidationSucceedsWhenEndIsAfterStart()
    {
        var command = new StartAndEndDateCommand
        {
            Start = DateTime.Now,
            End   = DateTime.Now.AddHours(1)
        };

        var validators = this.GetAllValidators <StartAndEndDateCommand>();
        var isValid    = validators.All(v => v.Validate(command).IsValid);

        Assert.IsTrue(isValid);
    }