I am getting
An exception of type 'System.NullReferenceException' occurred in *****Tests.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
How to correctly assign values to the binding model?
public class PersonRegistration
{
RegisterBindingModel model;
[TestMethod]
public void TestMethod1()
{
AccountController ac = new AccountController(userManager, loggingService);
model.UserName = "[email protected]";
var result = ac.Register(model);
Assert.AreEqual("User Registered Successfully", result);
}
I am getting the exception when executing model.UserName = "[email protected]";
public class RegisterBindingModel
{
public RegisterBindingModel();
[Display(Name = "User name")]
[Required]
public string UserName { get; set; }
}
Your
RegisterBindingModel modelnot initialized.So try something like: