Unable to get Default Constructor for class in Unit Test Project

Viewed 12402

I have created a unit test project. I get an exception specifying

Unable to get default constructor for class *****.Tests.Controllers.PersonRegistration

namespace *****.Tests.Controllers
{
[TestClass]
public class PersonRegistration
  {
    private ILoggingService _loggingService;
    private IUserManager _userManager;
    public PersonRegistration(IUserManager userManager, ILoggingService loggingService)
    {
        this._userManager = userManager;
        this._loggingService = loggingService;
    }

    [TestMethod]
    public void TestMethod1()
    {
        RegisterBindingModel model = new RegisterBindingModel();
        AccountController ac = new AccountController(_userManager, _loggingService);
        model.UserName = "test123@gmail.com";
        var result = ac.Register(model);
        Assert.AreEqual("User Registered Successfully", result);
    }
  }
}

To eradicate this issue some threads said to add an default constructor without parameters. So I added this also

public PersonRegistration()
 {
 }

But then I resolved the exception. But I am getting NULL values for _userManager and _loggingService

Null Values

How to resolve that issue. I do not want to generate null values when passing.

Please help me by suggesting a method to solve this question without using Moq or any other mocking frameworks.

1 Answers
Related