Exemplo n.º 1
0
        public static IEndpointBuilder <TContext> Map <TContext>(this IEndpointRouteBuilder <TContext> self) where TContext : Context
        {
            var endpointBuilder = new DefaultEndpointBuilder <TContext>(self.ServiceProvider);

            self.Map(endpointBuilder);

            return(endpointBuilder);
        }
        public void DefaultEndpointBuilder_Build_Empty()
        {
            // arange
            var endpoint = new DefaultEndpointBuilder <Context>(null)
                           // act
                           .Build();

            // assert
            Assert.Null(endpoint.MiddlewareDelegate);
            Assert.Null(endpoint.DisplayName);
            Assert.Empty(endpoint.Metadata);
        }
        public void DefaultEndpointBuilder_Build_WithMetadata()
        {
            // arange
            var endpoint = new DefaultEndpointBuilder <Context>(null)
                           // act
                           .WithMetadata("Hello World")
                           .Build();

            // assert
            Assert.Null(endpoint.MiddlewareDelegate);
            Assert.Null(endpoint.DisplayName);
            Assert.Collection(endpoint.Metadata,
                              m => { Assert.Equal("Hello World", m); }
                              );
        }
        public void DefaultEndpointBuilder_Build_WithMiddlwareDelegate()
        {
            // arange
            MiddlewareDelegate <Context> x = (context) => Task.CompletedTask;

            var endpoint = new DefaultEndpointBuilder <Context>(null)
                           // act
                           .WithMiddlewareDelegate(x)
                           .Build();

            // assert
            Assert.NotNull(endpoint.MiddlewareDelegate);
            Assert.Same(x, endpoint.MiddlewareDelegate);
            Assert.Null(endpoint.DisplayName);
            Assert.Empty(endpoint.Metadata);
        }