Repository: dotnet/aspnetcore
File: src/Mvc/Mvc.Core/test/ModelBinding/Metadata/DefaultModelMetadataProviderTest.cs (C#)

Code before:
        }
    }

    [Fact]
    public void GetMetadataForParameter_SuppliesEmptyAttributes_WhenParameterHasNoAttributes()
    {
        // Arrange
        var provider = CreateProvider();
        var parameters = typeof(ModelType)
            .GetMethod(nameof(ModelType.Method1))
            .GetParameters();

        // Act
        var metadata = provider.GetMetadataForParameter(parameters[0]);

        // Assert
        var defaultMetadata = Assert.IsType<DefaultModelMetadata>(metadata);

        // Not exactly "no attributes" due to pseudo-attributes on object.
        // After CoreCLR consistency fix, object.GetCustomAttributes() returns all pseudo-attributes.
        Assert.Equal(5, defaultMetadata.Attributes.Attributes.Count);
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr is SerializableAttribute);
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType().Name == "NullableContextAttribute");
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType().Name == "ClassInterfaceAttribute");
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType().Name == "ComVisibleAttribute");
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType().Name == "TypeForwardedFromAttribute");
    }

    [Fact]
    public void GetMetadataForParameter_SuppliesAttributes_WhenParamHasAttributes()
    {
        // Arrange
        var provider = CreateProvider();
        var parameters = typeof(ModelType)
            .GetMethod(nameof(ModelType.Method1))
            .GetParameters();

        // Act
        var metadata = provider.GetMetadataForParameter(parameters[1]);

        // Assert
        var defaultMetadata = Assert.IsType<DefaultModelMetadata>(metadata);
        Assert.Collection(
            // Take(2) to ignore SerializableAttribute on object.
            defaultMetadata.Attributes.Attributes.Take(2),
            attribute =>
            {
                var modelAttribute = Assert.IsType<ModelAttribute>(attribute);
                Assert.Equal("ParamAttrib1", modelAttribute.Value);
            },
            attribute =>

Review comment (suggestion):
Using string comparison with GetType().Name for attribute type checking is fragile and could break if the attribute type is renamed or moved to a different namespace. Consider using typeof() comparison or checking if the attribute is assignable from the expected type.
```suggestion
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType() == typeof(NullableContextAttribute));
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType() == typeof(ClassInterfaceAttribute));
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType() == typeof(ComVisibleAttribute));
        Assert.Contains(defaultMetadata.Attributes.Attributes, attr => attr.GetType() == typeof(TypeForwardedFromAttribute));
```

Code after:
        }
    }

    [Fact]
    public void GetMetadataForParameter_SuppliesEmptyAttributes_WhenParameterHasNoAttributes()
    {
        // Arrange
        var provider = CreateProvider();
        var parameters = typeof(ModelType)
            .GetMethod(nameof(ModelType.Method1))
            .GetParameters();

        // Act
        var metadata = provider.GetMetadataForParameter(parameters[0]);

        // Assert
        var defaultMetadata = Assert.IsType<DefaultModelMetadata>(metadata);

        // The parameter itself has no attributes
        Assert.Empty(defaultMetadata.Attributes.ParameterAttributes);

        // Type attributes exist (but we don't care what they are - that's runtime implementation detail)
        Assert.NotEmpty(defaultMetadata.Attributes.TypeAttributes);

        // Combined attributes = ParameterAttributes + TypeAttributes (when parameter has no attributes)
        Assert.Equal(defaultMetadata.Attributes.TypeAttributes, defaultMetadata.Attributes.Attributes);
    }

    [Fact]
    public void GetMetadataForParameter_SuppliesAttributes_WhenParamHasAttributes()
    {
        // Arrange
        var provider = CreateProvider();
        var parameters = typeof(ModelType)
            .GetMethod(nameof(ModelType.Method1))
            .GetParameters();

        // Act
        var metadata = provider.GetMetadataForParameter(parameters[1]);

        // Assert
        var defaultMetadata = Assert.IsType<DefaultModelMetadata>(metadata);
        Assert.Collection(
            // Take(2) to ignore SerializableAttribute on object.
            defaultMetadata.Attributes.Attributes.Take(2),
            attribute =>
            {
                var modelAttribute = Assert.IsType<ModelAttribute>(attribute);
                Assert.Equal("ParamAttrib1", modelAttribute.Value);
            },
            attribute =>