コード例 #1
0
 public CreateActorRouteMessage(Type actorType, string actorName, PoolKind poolType, params MessageRoute[] routes)
 {
     CheckForUniqueRoutes(routes);
     Routes    = routes;
     ActorType = actorType;
     ActorName = actorName;
     PoolKind  = poolType;
 }
コード例 #2
0
        public CreateHandlerRouteMessage(Type messageType, Type handlerType, string messageCorrelationProperty, PoolKind poolType)
        {
            MessageType = messageType;
            HandlerType = handlerType;
            MessageCorrelationProperty = messageCorrelationProperty;
            PoolType = poolType;

            Check();
        }
コード例 #3
0
        public async Task Should_return_200_request_When_hash_match_with_specific_pool(int payloadSize, PoolKind poolKind)
        {
            var buffer          = Encoding.UTF8.GetBytes(new string('-', payloadSize));
            var hash            = SHA256.Create().ComputeHash(buffer);
            var hashStringified = BitConverter.ToString(hash).Replace("-", "");

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Body = new MemoryStream(buffer);
            httpContext.Request.Headers[ContentHashValidationOptions.DefaultHeaderName] = hashStringified;
            httpContext.Request.Method = "POST";

            httpContext.SetEndpoint(new Endpoint(c => Task.CompletedTask,
                                                 new EndpointMetadataCollection(new ValidateContentHashAttribute()),
                                                 "someRoute"));

            var next       = new RequestDelegate(context => { context.Response.StatusCode = 200; return(Task.CompletedTask); });
            var middleware = new ContentHashValidationMiddleware(next, Options.Create(new ContentHashValidationOptions()
            {
                PoolKind = poolKind
            }), NullLogger <ContentHashValidationMiddleware> .Instance);

            await middleware.InvokeAsync(httpContext);

            Assert.Equal(200, httpContext.Response.StatusCode);
        }