コード例 #1
0
        public void Grades_Controller_Test_On_CreateModel_With_Invalid_Model()
        {
            //Arrange
            Guid     id    = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795");
            int      value = 10;
            DateTime date  = DateTime.Now;

            Grade expectedGrades = new Grade(value, date);

            expectedGrades.Id = id;

            GradeModel expectedModel = new GradeModel();

            expectedModel.Value = 1;
            var repo = Substitute.For <IRepository>();
            var sut  = new GradesController(repo);

            repo.Create(expectedGrades);

            //Act
            sut.ModelState.AddModelError("Title", "Title Required");
            var actual = sut.Create(expectedModel).Result;

            //Assert
            Assert.IsInstanceOfType(actual, typeof(ViewResult));
        }
コード例 #2
0
        public void Grades_Controller_Test_On_Create()
        {
            //Arrange
            var repo = Substitute.For <IRepository>();
            var sut  = new GradesController(repo);

            //Act
            var actual = sut.Create();

            //Assert
            Assert.IsInstanceOfType(actual, typeof(ViewResult));
        }
コード例 #3
0
        public void Create_ViewLoads()
        {
            var result = (ViewResult)controller.Create();

            Assert.AreEqual("Create", result.ViewName);
        }