コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }