Skip to content

Method injection fails with Type selectors #235

Open
@ENikS

Description

@ENikS

Description

When method is selected via provided Types it fails to reinterpret the Type as selector and not as value

To Reproduce

This works just fine:

[TestMethod]
public void Annotation_Optional_WithDefaultInt()
{
    // Arrange
    Container.RegisterType<Service>(new InjectionMethod(nameof(Service.OptionalDependencyAttributeWithDefaultInt)));

    // Act
    var result = Container.Resolve<Service>();

    // Assert
    Assert.AreEqual(result.Called, 12);
    Assert.AreEqual(result.Value, Service.DefaultInt);
}

When parameter type is added to properly select the method, it fails:

[TestMethod]
public void Annotation_Optional_WithDefaultInt()
{
    // Arrange
    Container.RegisterType<Service>(new InjectionMethod(nameof(Service.OptionalDependencyAttributeWithDefaultInt), typeof(int)));

    // Act
    var result = Container.Resolve<Service>();

    // Assert
    Assert.AreEqual(result.Called, 12);
    Assert.AreEqual(result.Value, Service.DefaultInt);
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions