Repository: dotnet/aspnetcore
File: src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/ApiDescriptionExtensionsTests.cs (C#)

Code before:
    [InlineData("api/todos", "/api/todos")]
    [InlineData("api/todos/{id}", "/api/todos/{id}")]
    [InlineData("api/todos/{id:int:min(10)}", "/api/todos/{id}")]
    [InlineData("{a}/{b}/{c=19}", "/{a}/{b}/{c}")]
    [InlineData("{a}/{b}/{c?}", "/{a}/{b}/{c}")]
    [InlineData("{a:int}/{b}/{c:int}", "/{a}/{b}/{c}")]
    [InlineData("", "/")]
    [InlineData("api", "/api")]
    [InlineData("{p1}/{p2}.{p3?}", "/{p1}/{p2}.{p3}")]
    public void MapRelativePathToItemPath_ReturnsItemPathForApiDescription(string relativePath, string expectedItemPath)
    {
        // Arrange
        var apiDescription = new ApiDescription
        {
            RelativePath = relativePath
        };

        // Act
        var itemPath = apiDescription.MapRelativePathToItemPath();

        // Assert
        Assert.Equal(expectedItemPath, itemPath);
    }

    [Theory]
    [InlineData("/~health", "~health", "/~health")]
    [InlineData("/~api/todos", "~api/todos", "/~api/todos")]
    [InlineData("/~api/todos/{id}", "~api/todos/{id}", "/~api/todos/{id}")]
    public void MapRelativePathToItemPath_WithRoutePattern_HandlesRoutesThatStartWithTilde(string rawPattern, string relativePath, string expectedItemPath)
    {
        // Arrange
        var routePattern = RoutePatternFactory.Parse(rawPattern);
        var apiDescription = new ApiDescription
        {
            RelativePath = relativePath,
            RoutePattern = routePattern
        };

        // Act
        var itemPath = apiDescription.MapRelativePathToItemPath();

        // Assert
        Assert.Equal(expectedItemPath, itemPath);
    }

    public static class HttpMethodTestData
    {
        public static IEnumerable<object[]> TestCases => new List<object[]>
        {
            new object[] { "GET", HttpMethod.Get },
            new object[] { "POST", HttpMethod.Post },

Review comment (suggestion):
`~` is for the start of the path. I don't think it's ever used after a `/`.

Code after:
    [InlineData("api/todos", "/api/todos")]
    [InlineData("api/todos/{id}", "/api/todos/{id}")]
    [InlineData("api/todos/{id:int:min(10)}", "/api/todos/{id}")]
    [InlineData("{a}/{b}/{c=19}", "/{a}/{b}/{c}")]
    [InlineData("{a}/{b}/{c?}", "/{a}/{b}/{c}")]
    [InlineData("{a:int}/{b}/{c:int}", "/{a}/{b}/{c}")]
    [InlineData("", "/")]
    [InlineData("api", "/api")]
    [InlineData("{p1}/{p2}.{p3?}", "/{p1}/{p2}.{p3}")]
    public void MapRelativePathToItemPath_ReturnsItemPathForApiDescription(string relativePath, string expectedItemPath)
    {
        // Arrange
        var apiDescription = new ApiDescription
        {
            RelativePath = relativePath
        };

        // Act
        var itemPath = apiDescription.MapRelativePathToItemPath();

        // Assert
        Assert.Equal(expectedItemPath, itemPath);
    }

    [Theory]
    [InlineData("/~health", "~health", "/~health")]
    [InlineData("/~api/todos", "~api/todos", "/~api/todos")]
    [InlineData("/~api/todos/{id}", "~api/todos/{id}", "/~api/todos/{id}")]
    [InlineData("~/health", "health", "/health")]
    [InlineData("~/api/todos", "api/todos", "/api/todos")]
    [InlineData("~/api/todos/{id}", "api/todos/{id}", "/api/todos/{id}")]
    public void MapRelativePathToItemPath_WithRoutePattern_HandlesRoutesThatStartWithTilde(string rawPattern, string relativePath, string expectedItemPath)
    {
        // Arrange
        var routePattern = RoutePatternFactory.Parse(rawPattern);
        var apiDescription = new ApiDescription
        {
            RelativePath = relativePath,
            RoutePattern = routePattern
        };

        // Act
        var itemPath = apiDescription.MapRelativePathToItemPath();

        // Assert
        Assert.Equal(expectedItemPath, itemPath);
    }

    public static class HttpMethodTestData
    {
        public static IEnumerable<object[]> TestCases => new List<object[]>