Ejemplo n.º 1
0
        public void NullArguments_ArgumentNullException()
        {
            var builder = new AppBuilder();
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicate(null, FuncNotImplemented));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicate(NotImplementedPredicate, (AppFunc)null));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicate(null, ActionNotImplemented));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicate(NotImplementedPredicate, (Action<IAppBuilder>)null));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(null, FuncNotImplemented, NotImplementedPredicate));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(FuncNotImplemented, null, NotImplementedPredicate));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(FuncNotImplemented, FuncNotImplemented, (Predicate)null));

            Assert.Throws<ArgumentNullException>(() => builder.MapPredicateAsync(null, FuncNotImplemented));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicateAsync(NotImplementedPredicateAsync, (AppFunc)null));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicateAsync(null, ActionNotImplemented));
            Assert.Throws<ArgumentNullException>(() => builder.MapPredicateAsync(NotImplementedPredicateAsync, (Action<IAppBuilder>)null));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(null, FuncNotImplemented, NotImplementedPredicateAsync));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(FuncNotImplemented, null, NotImplementedPredicateAsync));
            Assert.Throws<ArgumentNullException>(() => new MapPredicateMiddleware(FuncNotImplemented, FuncNotImplemented, (PredicateAsync)null));
        }
Ejemplo n.º 2
0
        public void PredicateAsyncFalseAction_PassThrough()
        {
            IDictionary<string, object> environment = CreateEmptyRequest();
            IAppBuilder builder = new AppBuilder();
            builder.MapPredicateAsync(FalsePredicateAsync, subBuilder => subBuilder.Run(FuncNotImplemented));
            builder.Run(Success);
            var app = builder.Build<AppFunc>();
            app(environment).Wait();

            Assert.Equal(200, environment["owin.ResponseStatusCode"]);
        }
Ejemplo n.º 3
0
        public void ChainedPredicatesAsync_Success()
        {
            IAppBuilder builder = new AppBuilder();
            builder.MapPredicateAsync(TruePredicateAsync, subBuilder =>
            {
                subBuilder.MapPredicateAsync(FalsePredicateAsync, FuncNotImplemented);
                subBuilder.MapPredicateAsync(TruePredicateAsync, subBuilder1 => { subBuilder.MapPredicateAsync(TruePredicateAsync, Success); });
                subBuilder.Run(FuncNotImplemented);
            });
            var app = builder.Build<AppFunc>();

            IDictionary<string, object> environment = CreateEmptyRequest();
            app(environment).Wait();
            Assert.Equal(200, environment["owin.ResponseStatusCode"]);
        }
Ejemplo n.º 4
0
        public void PredicateAsyncTrueAction_BranchTaken()
        {
            IDictionary<string, object> environment = CreateEmptyRequest();
            IAppBuilder builder = new AppBuilder();
            builder.MapPredicateAsync(TruePredicateAsync, subBuilder => subBuilder.Run(Success));
            var app = builder.Build<AppFunc>();
            app(environment).Wait();

            Assert.Equal(200, environment["owin.ResponseStatusCode"]);
        }