public async Task RouteAsync_NoMatch()
        {
            // Arrange
            var routes = new RouteCollection();

            var route1 = CreateRoute(accept: false);

            routes.Add(route1.Object);

            var route2 = CreateRoute(accept: false);

            routes.Add(route2.Object);

            var context = CreateRouteContext("/Cool");

            // Act
            await routes.RouteAsync(context);

            // Assert
            route1.Verify(e => e.RouteAsync(It.IsAny <RouteContext>()), Times.Exactly(1));
            route2.Verify(e => e.RouteAsync(It.IsAny <RouteContext>()), Times.Exactly(1));
            Assert.False(context.IsHandled);

            Assert.Empty(context.RouteData.Routers);
        }
        public async Task RouteAsync_SecondMatches()
        {
            // Arrange
            var routes = new RouteCollection();

            var route1 = CreateRoute(accept: false);

            routes.Add(route1.Object);

            var route2 = CreateRoute(accept: true);

            routes.Add(route2.Object);

            var context = CreateRouteContext("/Cool");

            // Act
            await routes.RouteAsync(context);

            // Assert
            route1.Verify(e => e.RouteAsync(It.IsAny <RouteContext>()), Times.Exactly(1));
            route2.Verify(e => e.RouteAsync(It.IsAny <RouteContext>()), Times.Exactly(1));
            Assert.True(context.IsHandled);

            Assert.Equal(1, context.RouteData.Routers.Count);
            Assert.Same(route2.Object, context.RouteData.Routers[0]);
        }
        private static async Task <TestSink> SetUp(bool enabled, bool handled)
        {
            // Arrange
            var sink = new TestSink(
                TestSink.EnableWithTypeName <RouteCollection>,
                TestSink.EnableWithTypeName <RouteCollection>);
            var loggerFactory = new TestLoggerFactory(sink, enabled);

            var routes = new RouteCollection();
            var route  = CreateRoute(accept: handled);

            routes.Add(route.Object);

            var context = CreateRouteContext("/Cool", loggerFactory);

            // Act
            await routes.RouteAsync(context);

            return(sink);
        }
        private static async Task<TestSink> SetUp(bool enabled, bool handled)
        {
            // Arrange
            var sink = new TestSink(
                TestSink.EnableWithTypeName<RouteCollection>,
                TestSink.EnableWithTypeName<RouteCollection>);
            var loggerFactory = new TestLoggerFactory(sink, enabled);

            var routes = new RouteCollection();
            var route = CreateRoute(accept: handled);
            routes.Add(route.Object);

            var context = CreateRouteContext("/Cool", loggerFactory);

            // Act
            await routes.RouteAsync(context);

            return sink;
        }
        public async Task RouteAsync_NoMatch()
        {
            // Arrange
            var routes = new RouteCollection();
            var route1 = CreateRoute(accept: false);
            routes.Add(route1.Object);

            var route2 = CreateRoute(accept: false);
            routes.Add(route2.Object);

            var context = CreateRouteContext("/Cool");

            // Act
            await routes.RouteAsync(context);

            // Assert
            route1.Verify(e => e.RouteAsync(It.IsAny<RouteContext>()), Times.Exactly(1));
            route2.Verify(e => e.RouteAsync(It.IsAny<RouteContext>()), Times.Exactly(1));
            Assert.False(context.IsHandled);

            Assert.Empty(context.RouteData.Routers);
        }
        public async Task RouteAsync_SecondMatches()
        {
            // Arrange

            var routes = new RouteCollection();
            var route1 = CreateRoute(accept: false);
            routes.Add(route1.Object);

            var route2 = CreateRoute(accept: true);
            routes.Add(route2.Object);

            var context = CreateRouteContext("/Cool");

            // Act
            await routes.RouteAsync(context);

            // Assert
            route1.Verify(e => e.RouteAsync(It.IsAny<RouteContext>()), Times.Exactly(1));
            route2.Verify(e => e.RouteAsync(It.IsAny<RouteContext>()), Times.Exactly(1));
            Assert.True(context.IsHandled);

            Assert.Equal(1, context.RouteData.Routers.Count);
            Assert.Same(route2.Object, context.RouteData.Routers[0]);
        }