Ejemplo n.º 1
0
        public string DeleteStudent(string id)
        {
            var errors = new List<string>();
            var repository = new StudentRepository(this.entities);
            var service = new StudentService(repository);
            service.DeleteStudent(id, ref errors);

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

            return "error";
        }
        public void DeleteStudentErrorTest()
        {
            //// Arrange
            var errors = new List<string>();

            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);

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

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Ejemplo n.º 3
0
        public void DeleteStudent()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);

            mockRepository.Setup(x => x.DeleteStudent("aaaaaa", ref errors));

            //// Act
            studentService.DeleteStudent("aaaaaa", ref errors);

            //// Assert
            mockRepository.Verify(x => x.DeleteStudent("aaaaaa", ref errors), Times.Once());
        }