public void Create_Test() { var repo = new Mock <ISchoolRepository <int> >(); var controller = new ManageSchoolsController(repo.Object); var result = controller.Create(); var viewResult = Assert.IsType <ViewResult>(result); Assert.Null(viewResult.ViewName); }
public void Create_Post_InvalidModelState_Test() { var dbContext = _serviceProvider.GetRequiredService <AngularDbContext>(); var repo = new Mock <ISchoolRepository <int> >(); var controller = new ManageSchoolsController(repo.Object); controller.ModelState.AddModelError("error", "error"); var result = controller.Create((new Mock <SchoolModel>()).Object); var viewResult = Assert.IsType <ViewResult>(result); Assert.Null(viewResult.ViewName); }