Repository: dotnet/aspnetcore
File: src/Components/Endpoints/test/Binding/FormDataMapperTests.cs (C#)

Code before:
            new FormFile(new MemoryStream(Encoding.UTF8.GetBytes(expectedString2)), 0, expectedString2.Length, "file", "file2.txt")
        };
        var data = new Dictionary<string, StringValues>();
        var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture, expected);
        var errors = new List<FormDataMappingError>();
        reader.ErrorHandler = (key, message, attemptedValue) =>
        {
            errors.Add(new FormDataMappingError(key, message, attemptedValue));
        };
        reader.PushPrefix("file");
        var options = new FormDataMapperOptions();

        // Act
        var result = CallDeserialize(reader, options, typeof(IReadOnlyList<IBrowserFile>));

        // Assert
        var browserFiles = Assert.IsAssignableFrom<IReadOnlyList<IBrowserFile>>(result);
        // First file
        var browserFile1 = browserFiles[0];
        Assert.Equal("file", browserFile1.Name);
        Assert.Equal(expectedString1.Length, browserFile1.Size);
        var buffer1 = new byte[browserFile1.Size];
        browserFile1.OpenReadStream().Read(buffer1);
        Assert.Equal(expectedString1, Encoding.UTF8.GetString(buffer1, 0, buffer1.Length));
        // Second files
        var browserFile2 = browserFiles[0];
        Assert.Equal("file", browserFile2.Name);
        Assert.Equal(expectedString1.Length, browserFile2.Size);
        var buffer2 = new byte[browserFile2.Size];
        browserFile1.OpenReadStream().Read(buffer2);
        Assert.Equal(expectedString1, Encoding.UTF8.GetString(buffer2, 0, buffer2.Length));
    }

    [Fact]
    public void RecursiveTypes_Comparer_SortsValues_Correctly()
    {
        // Arrange
        var data = new Dictionary<string, StringValues>()
        {
            ["customerId"] = "20",
            ["customer[Id]"] = "20",
            ["customer.Id"] = "20"
        };
        var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture);
        reader.PushPrefix("customer");

        // Act
        var result = reader.CurrentPrefixExists();

        // Assert
        Assert.True(result);

Review comment (bug):
This line correctly fixes the bug where browserFile2 was incorrectly assigned to browserFiles[0] instead of browserFiles[1], but the change appears to be fixing a pre-existing test bug rather than being directly related to the Name property fix.

Code after:
            new FormFile(new MemoryStream(Encoding.UTF8.GetBytes(expectedString2)), 0, expectedString2.Length, "file", "file2.txt")
        };
        var data = new Dictionary<string, StringValues>();
        var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture, expected);
        var errors = new List<FormDataMappingError>();
        reader.ErrorHandler = (key, message, attemptedValue) =>
        {
            errors.Add(new FormDataMappingError(key, message, attemptedValue));
        };
        reader.PushPrefix("file");
        var options = new FormDataMapperOptions();

        // Act
        var result = CallDeserialize(reader, options, typeof(IReadOnlyList<IBrowserFile>));

        // Assert
        var browserFiles = Assert.IsAssignableFrom<IReadOnlyList<IBrowserFile>>(result);
        // First file
        var browserFile1 = browserFiles[0];
        Assert.Equal("file1.txt", browserFile1.Name);
        Assert.Equal(expectedString1.Length, browserFile1.Size);
        var buffer1 = new byte[browserFile1.Size];
        browserFile1.OpenReadStream().Read(buffer1);
        Assert.Equal(expectedString1, Encoding.UTF8.GetString(buffer1, 0, buffer1.Length));
        // Second files
        var browserFile2 = browserFiles[1];
        Assert.Equal("file2.txt", browserFile2.Name);
        Assert.Equal(expectedString2.Length, browserFile2.Size);
        var buffer2 = new byte[browserFile2.Size];
        browserFile2.OpenReadStream().Read(buffer2);
        Assert.Equal(expectedString2, Encoding.UTF8.GetString(buffer2, 0, buffer2.Length));
    }

    [Fact]
    public void RecursiveTypes_Comparer_SortsValues_Correctly()
    {
        // Arrange
        var data = new Dictionary<string, StringValues>()
        {
            ["customerId"] = "20",
            ["customer[Id]"] = "20",
            ["customer.Id"] = "20"
        };
        var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture);
        reader.PushPrefix("customer");

        // Act
        var result = reader.CurrentPrefixExists();

        // Assert
        Assert.True(result);