Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get default constructor for Integration class ninject
    primarykey
    data
    text
    <p>I'm new on using ninject and Dependency Injection, and have a problem using it.</p> <p>I try to using Ninject on my class libray, and building an integration tests. now, I see in many example that, for using ninject is just specified the DI Module like this:</p> <pre><code>Public Class DIModule : NinjectModule public override void Load() { Bind&lt;IUSAServices&gt;().To&lt;USAServices&gt;(); } </code></pre> <p>And then on my test class, I try to call my dependency is like this:</p> <pre><code>[TestClass] public class USAIntegrationTests { private readonly IUSAServices _usaService; public USAIntegrationTests(IUSAServices usaServices) { _usaService = usaServices; } [TestMethod] public void ValidateUserTests() { Assert.IsTrue(_usaService.ValidateUser("username1", "password1")); } } </code></pre> <p>And Getting this error:</p> <pre><code>Unable to get default constructor for class USATests.IntegrationTests.USAIntegrationTests. </code></pre> <p>However I read the documentation and tried like this:</p> <pre><code>[TestClass] public class USAIntegrationTests { private readonly IUSAServices _usaService; public USAIntegrationTests() { using (IKernel kernel = new StandardKernel(new DIModule())) { _usaService = kernel.Get&lt;IUSAServices&gt;(); } } [TestMethod] public void ValidateUserTests() { Assert.IsTrue(_usaService.ValidateUser("mantab", "banget")); } } </code></pre> <p>The test is works properly. My question is, why I getting that error? is that some way to get around it? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload