Beispiel #1
0
        public void AddToClassShouldSaveChange()
        {
            //ARRANGE
            var          classId   = Guid.NewGuid();
            const string teacherId = "51f213d1-17a7-4e72-8aac-035d197a4f9f";

            var model = new AddTeacherToClassViewModel {
                TeacherId = teacherId, Class = new ClassEntity {
                    Id = classId
                }
            };

            var logic = new Mock <IClassLogic>();

            logic
            .Setup(x => x.AddTeacherToClass(teacherId, classId))
            .Verifiable("Should add teacher to class");

            var controller = new TeacherController(null, null, logic.Object, null, null, null, null);

            //ACT
            var result = controller.AddClass(model) as RedirectToRouteResult;

            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.AreEqual("Manage", result.RouteValues["Action"]);
        }
Beispiel #2
0
        public void AddToClassShouldDisplayTheCorretView()
        {
            //ARRANGE
            var teacherId = "51f213d1-17a7-4e72-8aac-035d197a4f9f";
            var logic     = new Mock <IClassLogic>();

            logic
            .Setup(x => x.GetAll())
            .Returns(new List <ClassEntity>())
            .Verifiable("Should get list of classes to display");

            var controller = new TeacherController(null, null, logic.Object, null, null, null, null);

            //ACT
            var result = controller.AddClass(teacherId) as ViewResult;


            //ASSERT
            logic.Verify();

            Assert.NotNull(result);
            Assert.NotNull(result.Model);
            Assert.That(result.ViewName, Is.EqualTo("AddClass"));
        }