public void SentinelTest_ValidationDelegatePasses()
        {
            TestingUtils.ResetSentinel();
            var sentinel = new Sentinel(reqDelegate, new RoutesRepository());

            Sentinel.RegisterValidationDelegate(claimValidationDelegate);
            var httpContext = new DefaultHttpContext();
            var result      = sentinel.Invoke(httpContext);

            Assert.NotNull(result);
            Assert.Equal((int)HttpStatusCode.Created, httpContext.Response.StatusCode);
        }
        public void SentinelTest_ThisOneShouldntPassButDoes()
        {
            TestingUtils.ResetSentinel();
            TestingUtils.ResetRoutesRepository();

            var routesRepository = new RoutesRepository();

            routesRepository.RegisterRoutesAsync(new List <IRouteDefinitions>()
            {
                new SpecialRouteTemplateRoutes()
            }).Wait();
            var httpContext = new DefaultHttpContext();

            httpContext.Response.Body = new MemoryStream();
            var request = new DefaultHttpRequest(httpContext)
            {
                Method = HttpMethod.Post.Method,
                Path   = "/v1/yolo/nolo/thisIsDefinitelyNotAnInteger",
                Query  = new QueryCollection(new Dictionary <string, Microsoft.Extensions.Primitives.StringValues>()
                {
                    { "No", "true" }
                }),
                Body = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new TestingType()
                {
                    Yo = "lo", No = "low"
                })))
            };

            httpContext.Items.Add("ExpectedClaims", new List <Claim>()
            {
                new Claim("PityTheFoolType", "low"),
                new Claim("PityTheFoolJsonPath", "low"),
                new Claim("PityTheFoolKeyValue", "true"),
                new Claim("PityTheFoolRegex", "yolo"),
            });
            var sentinel = new Sentinel(reqDelegate, routesRepository);
            var result   = sentinel.Invoke(httpContext);

            Assert.NotNull(request);
            Assert.NotNull(result);
            Assert.Equal((int)HttpStatusCode.Created, httpContext.Response.StatusCode);
        }