public void When_Constructed_Then_Initialised() { // Arrange. // Act. var model = new EndPointsViewModel(); // Assert. model.Should().NotBeNull(); model.EndPoints.Should().NotBeNull(); model.EndPoints.Should().BeEmpty(); }
public IActionResult EndPoints() { var actionDescriptors = _actionDescriptorCollectionProvider.ActionDescriptors.Items; var model = new EndPointsViewModel(); model.EndPoints = actionDescriptors .Select(ad => new EndPoint() { Action = ad.RouteValues["action"], Controller = ad.RouteValues["controller"], Methods = string.Join(", ", ad.ActionConstraints?.OfType <HttpMethodActionConstraint>().SingleOrDefault()?.HttpMethods ?? new string[] { "GET" }), }).ToList(); return(View(model)); }