public void NullArguments_ArgumentNullException()
        {
            var builder      = new ApplicationBuilder(serviceProvider: null);
            var noMiddleware = new ApplicationBuilder(serviceProvider: null).Build();
            var noOptions    = new MapWhenOptions();

            Assert.Throws <ArgumentNullException>(() => builder.MapWhen(null, UseNotImplemented));
            Assert.Throws <ArgumentNullException>(() => builder.MapWhen(NotImplementedPredicate, configuration: null));
            Assert.Throws <ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
            Assert.Throws <ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
            Assert.Throws <ArgumentNullException>(() => new MapWhenMiddleware(null, noOptions));
            Assert.Throws <ArgumentNullException>(() => new MapWhenMiddleware(noMiddleware, null));
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance of <see cref="MapWhenMiddleware"/>.
        /// </summary>
        /// <param name="next">The delegate representing the next middleware in the request pipeline.</param>
        /// <param name="options">The middleware options.</param>
        public MapWhenMiddleware(RequestDelegate next, MapWhenOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next    = next;
            _options = options;
        }