public void MapConventions() { //Arrange var classAttributes = Attribute.GetCustomAttributes(typeof(TestEndpoint)); var conventions = new EndpointRoutingConvention(new List <IEndpointMetadataEnricher>() { new RouteEndpointMetadataEnricher(Options.Create(new SimpleEndpointsConfiguration()), NullLogger <RouteEndpointMetadataEnricher> .Instance), new HttpMethodEndpointMetadataEnricher(Options.Create(new SimpleEndpointsConfiguration()), NullLogger <HttpMethodEndpointMetadataEnricher> .Instance) }, NullLogger <EndpointRoutingConvention> .Instance); var controller = new ControllerModel(typeof(TestEndpoint).GetTypeInfo(), classAttributes) { Selectors = { new SelectorModel { AttributeRouteModel = new AttributeRouteModel{ Template = "route" }, EndpointMetadata ={ } } }, ControllerName = nameof(TestEndpoint) }; //Act conventions.Apply(new ApplicationModel { Controllers = { controller } }); controller.Selectors[0].AttributeRouteModel.Template.ShouldBe("route"); //Assert controller.Selectors[0].EndpointMetadata.Count.ShouldBe(1); controller.Selectors[0].EndpointMetadata.First().ShouldBeOfType <HttpMethodMetadata>(); controller.Selectors[0].EndpointMetadata.OfType <HttpMethodMetadata>().First().HttpMethods .ShouldBe(new[] { "GET" }); }
public ConfigureMvcOptionsForSimpleEndpoints(EndpointRoutingConvention endpointRoutingConvention) { _endpointRoutingConvention = endpointRoutingConvention; }