Пример #1
0
        public string UpdateStudent(Student student)
        {
            var errors = new List<string>();
            var repository = new StudentRepository(this.entities);
            var service = new StudentService(repository);
            service.UpdateStudent(student, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
Пример #2
0
        public void UpdateStudentErrorTest()
        {
            //// Arrange
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);

            //// Act
            studentService.UpdateStudent(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Пример #3
0
        public void UpdateStudentErrorTest4()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);
            var student = new Student { StudentId = "aaaaaa", Email = "c@c" };

            //// Act
            studentService.UpdateStudent(student, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Пример #4
0
        public void UpdateStudent()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);
            var student = new Student { StudentId = "aaaaaa", Email = "*****@*****.**" };

            mockRepository.Setup(x => x.UpdateStudent(student, ref errors));

            //// Act
            studentService.UpdateStudent(student, ref errors);

            //// Assert
            mockRepository.Verify(x => x.UpdateStudent(student, ref errors), Times.Once());
        }