예제 #1
0
        public async Task ValidateAsync_WhenInputValidationResultsContainsErrors_ShouldReturnFalse(
            [Frozen] HubRequestValidationResult validationResult,
            [Frozen] Mock <IChangeOfChargesInputValidator> inputValidator,
            [NotNull] ChangeOfChargesCommandHandlerTestable sut)
        {
            validationResult.Add(new ValidationError("some error code", "some error message"));
            inputValidator.Setup(iv => iv.ValidateAsync(It.IsAny <ChangeOfChargesMessage>()))
            .ReturnsAsync(validationResult);

            var result = await sut.CallValidateAsync(new ChangeOfChargesMessage()).ConfigureAwait(false);

            result.Should().Be(false);
        }
예제 #2
0
        public async Task ValidateAsync_WhenValidationResultsContainsNoErrors_ShouldReturnTrue(
            [Frozen] Mock <IChangeOfChargesDomainValidator> changeOfChargesValidationRules,
            [Frozen] Mock <IChangeOfChargesInputValidator> inputValidator,
            [NotNull] ChangeOfChargesCommandHandlerTestable sut)
        {
            inputValidator.Setup(iv => iv.ValidateAsync(It.IsAny <ChangeOfChargesMessage>()))
            .ReturnsAsync(new HubRequestValidationResult("some mRID"));

            changeOfChargesValidationRules.Setup(x =>
                                                 x.ValidateAsync(It.IsAny <ChangeOfChargesMessage>()))
            .ReturnsAsync(new HubRequestValidationResult("some mRID"));

            var result = await sut.CallValidateAsync(new ChangeOfChargesMessage()).ConfigureAwait(false);

            result.Should().Be(true);
        }