public void GetProfileById_Test_Is_Generete_Exeption_If_Id_less_zero()
 {
     //Arrange
     var logger = new Mock<ILogger>();
     var iRepository = new Mock<IRepository<Teacher>>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     var iSubjectServic= new Mock<ISubjectService>();
     iUnitOfWork.Setup(st => st.TeacherRepository).Returns(iRepository.Object);
     var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object,iSubjectServic.Object);
     int anyIdLessZero = -2;
     //Act
     var teacher = teacherService.GetProfileById(anyIdLessZero);
 }
        public void GetProfileById_Test_Is_Invoke_Repo_GetById()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iRepository = new Mock<IRepository<Teacher>>();
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iSubjectServic = new Mock<ISubjectService>();

            iUnitOfWork.Setup(st => st.TeacherRepository).Returns(iRepository.Object);
            iRepository.Setup(inv => inv.GetById(It.Is<int>(i => i > 0))).Returns(this.teacher);
            var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object, iSubjectServic.Object);
            int anyIdMoreZero = 3;
            //Act
               teacherService.GetProfileById(anyIdMoreZero);
            //Assert
               iRepository.Verify(inv => inv.GetById(anyIdMoreZero), Times.Once);
        }
        public void AddTeacherUnitTest()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iRepositoryTeacher = new Mock<IRepository<Teacher>>();
            var iRepositorySubject = new Mock<IRepository<Subject>>();
            var iSubjectServic = new Mock<ISubjectService>();

            this.teacher.Subjects = this.subjects;
            iUnitOfWork.Setup(st => st.TeacherRepository).Returns(iRepositoryTeacher.Object);
            iUnitOfWork.Setup(st => st.SubjectRepository).Returns(iRepositorySubject.Object);
            var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object,iSubjectServic.Object);
            //Act
            teacherService.AddTeacher(this.teacher);
            //Assert
               iRepositoryTeacher.Verify(inv => inv.Add(this.teacher), Times.Once);
        }
        public void GetTeachers_Test_If_Get_All_Teacher_And_Invoke_GetAll_repository_Method()
        {
            //Arange
            var logger = new Mock<ILogger>();
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iRepository = new Mock<IRepository<Teacher>>();
            var iSubjectServic = new Mock<ISubjectService>();

            iUnitOfWork.Setup(st => st.TeacherRepository).Returns(iRepository.Object);
            var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object, iSubjectServic.Object);
            //Act
            teacherService.GetAllTeachers();
            //Assert
            iRepository.Verify(inv => inv.GetAll(), Times.Once);
        }
        public void UpdateProfileUnitTest()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iRepository = new Mock<IRepository<Teacher>>();
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iSubjectServic = new Mock<ISubjectService>();

            iUnitOfWork.Setup(st => st.TeacherRepository).Returns(iRepository.Object);
            var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object, iSubjectServic.Object);
            //Act
            teacherService.UpdateProfile(this.teacher);
            //Assert
            iRepository.Verify(inv => inv.Update(this.teacher), Times.Once);
        }
        public void RemoveTeacherUnit5Test()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iRepository = new Mock<IRepository<Teacher>>();
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iSubjectServic = new Mock<ISubjectService>();

            var teacherService = new TeacherService(logger.Object, iUnitOfWork.Object,iSubjectServic.Object);
            iUnitOfWork.SetupGet(u => u.TeacherRepository).Returns(iRepository.Object);
            //Act
            teacherService.RemoveTeacher(this.teacher);
            //Assert
            iRepository.Verify(inv => inv.Delete(this.teacher), Times.Once);
        }
Exemplo n.º 7
0
 public TeacherController(ILogger logger , TeacherService teacherService , IAccountService accService)
 {
     this.logger = logger;
     this.teacherService = teacherService;
     this.accountService = accService;
 }