예제 #1
0
        public void CanGetSubjects()
        {
            // Arrange
            _unitOfWorkMock.Setup(m => m.SubjectRepository.Get(null, null, "")).Returns(_subjects);
            ManageController controller = new ManageController(_unitOfWorkMock.Object, _accountMock.Object);

            // Act
            var actual = controller.GetSubjects() as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <List <IDictionary <string, object> > >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0 && result.Count < 10);
        }
예제 #2
0
        public void CanGetComments()
        {
            // Arrange
            _unitOfWorkMock.Setup(m => m.CommentRepository.Get(null, null, "")).Returns(_comments);
            TaskController controller = new TaskController(_unitOfWorkMock.Object, null, null);

            // Act
            var actual = controller.GetComments(1) as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <List <IDictionary <string, object> > >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 5);
            Assert.AreEqual("CommentContent5", result[0]["Content"]);
        }
예제 #3
0
        public void CanGetSubjectById()
        {
            // Arrange
            var subjId = 3;

            _unitOfWorkMock.Setup(m => m.SubjectRepository.GetByID(subjId)).Returns(_subjects.Single(s => s.ID == subjId));
            ManageController controller = new ManageController(_unitOfWorkMock.Object, _accountMock.Object);

            // Act
            var actual = controller.GetSubject(subjId) as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <IDictionary <string, object> >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Name3", result["SubjectName"]);
        }
예제 #4
0
        public void CanGetAvailableGroups()
        {
            // Arrange
            _unitOfWorkMock.Setup(m => m.TeachersGroupRepository.Get(null, null, "")).Returns(_teacherGroups);
            _unitOfWorkMock.Setup(m => m.GroupRepository.Get(null, null, "")).Returns(_groups);

            ManageController controller = new ManageController(_unitOfWorkMock.Object, _accountMock.Object);

            // Act
            var actual = controller.GetAvailableGroups() as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <List <IDictionary <string, object> > >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 6);
        }
예제 #5
0
        public void CanGetSubjectsByTeacher()
        {
            // Arrange
            _unitOfWorkMock.Setup(m => m.SubjectRepository.Get(null, null, "")).Returns(_subjects);
            _accountMock.Setup(m => m.GetCurrentUserId()).Returns("teacherId #1");

            TaskController controller = new TaskController(_unitOfWorkMock.Object, _accountMock.Object, null);

            // Act
            var actual = controller.GetSubjectsByTeacher() as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <List <IDictionary <string, object> > >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count > 0);
        }
예제 #6
0
        public void CanGetTasksForStudent()
        {
            // Arrange
            _taskMock.Setup(m => m.GetStudentTasks(_testUserId)).Returns(_studentTasks);
            _accountMock.Setup(m => m.CurrentUserIsInRole("Student")).Returns(true);
            TaskController controller = new TaskController(null, _accountMock.Object, _taskMock.Object);

            // Act
            var actual = controller.GetTasks() as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <List <IDictionary <string, object> > >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Count == 10);

            Assert.IsTrue(result.All(r => r["Group"] == null));
            Assert.IsTrue(result.Any(r => (bool)r["IsDone"] == true));
        }
예제 #7
0
        public void CanGetTaskDetailByTaskId()
        {
            // Arrange
            var taskId = 1;

            _unitOfWorkMock.Setup(m => m.TaskDetailRepository.GetByID(taskId)).Returns(_taskDetail.Single(t => t.ID == taskId));
            _unitOfWorkMock.Setup(m => m.CommentRepository.Get(null, null, "")).Returns(_comments);

            TaskController controller = new TaskController(_unitOfWorkMock.Object, null, null);

            // Act
            var actual = controller.GetTaskDetail(taskId) as JsonResult;
            var result = JsonObjectRepresentor.GetJsonObjectRepresentation <IDictionary <string, object> >(actual);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("TaskTitle1", result["TaskTitle"]);
            Assert.AreEqual("PMI - 32", result["Group"]);
            Assert.IsNotNull(result["Comments"]);
        }