Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to bind generic list #37

Open
twawrzyczny opened this issue Nov 9, 2018 · 0 comments
Open

Unable to bind generic list #37

twawrzyczny opened this issue Nov 9, 2018 · 0 comments

Comments

@twawrzyczny
Copy link

This seemed to be possible in 3.2.0.0 but now it seems to always return an empty list when binding a generic list.

Here's an example:
public class Bunny
{
public string Name { get; set; }
}

[TestFixture]
public class BunnyTestFixture
{
    private MoqMockingKernel kernel;

    public BunnyTestFixture()
    {
        kernel = new MoqMockingKernel();
        kernel.Bind<List<Bunny>>().ToMethod(c => BunnyTestFixture.BuildMyBunnyArmy());
    }

    private static List<Bunny> BuildMyBunnyArmy()
    {
        return new List<Bunny>
        {
            new Bunny {Name = "Bugs"},
            new Bunny {Name = "Calvin"},
            new Bunny {Name = "Carter"},
            new Bunny {Name = "Dora"}
        };
    }

    [Test]
    public void TestKernelBinding()
    {
        var bunnyArmy = kernel.Get<List<Bunny>>();

        Assert.IsTrue(bunnyArmy.Count > 0);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant