Hi , I am looking for solution to handle database dependency code of method in unit test case
Below is My Registration Controller Class-
public class RegistrationController : Controller { public async Task<ActionResult> Register(RegisterViewModel model) { // Validate uniqueness of UserName requested var uniqueUserNameQuery = UserInfoProvider.GetUsers().WhereEquals("UserName", model.UserName); if (uniqueUserNameQuery.Count > 0) { ModelState.AddModelError("UserName", "UserName is not available!"); } if (!ModelState.IsValid) { List<StateInfo> stateInfos = GetStateSelection(); model.State = new SelectList(stateInfos, "StateName", "StateDisplayName"); return View(model); } } }
when i call above method in test case it will throw exception at point where i am calling UserInfoProvider.GetUsers because dependency is not handled in test case
so how to create fake data for user provider and how to pass it in method
Look at the example on MVC DancingGoat web site.
Please, sign in to be able to submit a new answer.