Exemplo n.º 1
0
        public void ShouldThrowExceptionWhenNullAsNextWasPassed()
        {
            // Arrange
            _validators = Enumerable.Empty <IValidator <SampleRequest> >();
            _sut        = new FluentValidationCollectionPipelineBehavior <SampleRequest, SampleResponse>(_validators);
            var request           = new SampleRequest();
            var cancellationToken = CancellationToken.None;
            const RequestHandlerDelegate <SampleResponse>?next = null;

            // Act
#pragma warning disable CS8604 // Possible null reference argument.
#pragma warning disable SA1115 // Parameter should follow comma
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
            Func <Task> func = async() => await _sut.Handle(
                request,
                cancellationToken,

                // ReSharper disable once ExpressionIsAlwaysNull
                next).ConfigureAwait(false);

#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning restore SA1115 // Parameter should follow comma
#pragma warning restore CS8604 // Possible null reference argument.

            // Assert
            using (new AssertionScope())
            {
                func.Should().Throw <ArgumentNullException>();
            }
        }
Exemplo n.º 2
0
 public async Task ShouldProcessCorrectlyWhenNoValidatorUsedAsync()
 {
     // Arrange
     _validators = Enumerable.Empty <IValidator <SampleRequest> >();
     _sut        = new FluentValidationCollectionPipelineBehavior <SampleRequest, SampleResponse>(_validators);
     var request = new SampleRequest();
     var cancellationToken = CancellationToken.None;
 public async Task ShouldProcessCorrectlyWhenNoValidatorUsedAsync()
 {
     // Arrange
     _sut = new FluentValidationPipelineBehavior <SampleRequest, SampleResponse>(null);
     var request = new SampleRequest();
     var cancellationToken = CancellationToken.None;