public void Holidays_GetById_Test_Is_Generete_Exeption_If_Id_less_zero()
 {
     //Arrange
     var logger = new Mock<ILogger>();
     var iRepository = new Mock<IRepository<Holidays>>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     iUnitOfWork.Setup(st => st.HolidaysRepository).Returns(iRepository.Object);
     var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);
     int anyIdLessZero = -5;
     //Act
     var tempholidays = holidaysService.GetHolidaysById(anyIdLessZero);
 }
 public void Holidays_AddUnitTest()
 {
     //Arrange
     var logger = new Mock<ILogger>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     var iRepositoryHolidays = new Mock<IRepository<Holidays>>();
     iUnitOfWork.Setup(st => st.HolidaysRepository).Returns(iRepositoryHolidays.Object);
     var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);
     var tmp = holidaysService.GetAllHolidays();
     //Act
     holidaysService.AddHolidays(this.holidays);
     //Assert
     iRepositoryHolidays.Verify(inv => inv.Add(this.holidays), Times.Once);
 }
        public void HolidaysGetById_Test_Is_Invoke_Repo_GetById()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iRepository = new Mock<IRepository<Holidays>>();
            var iUnitOfWork = new Mock<IUnitOfWork>();

            iUnitOfWork.Setup(st => st.HolidaysRepository).Returns(iRepository.Object);
            iRepository.Setup(inv => inv.GetById(It.Is<int>(i => i > 0))).Returns(this.holidays);
            var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);
            int anyIdMoreZero = 2;
            //Act
            holidaysService.GetHolidaysById(anyIdMoreZero);
            //Assert
            iRepository.Verify(inv => inv.GetById(anyIdMoreZero), Times.Once);
        }
        public void Holidays_GetHolidaysByDate()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var date = new DateTime(2015, 05, 06);
            DateTime monday = date;
            DateTime friday = monday.AddDays(Constants.CountOfWorkingDaysInWeek - 1);
            var iUnitOfWork = new Mock<IUnitOfWork>();
            var iRepositoryHolidays = new Mock<IRepository<Holidays>>();
            iUnitOfWork.Setup(st => st.HolidaysRepository).Returns(iRepositoryHolidays.Object);

            var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);

            //Act
            holidaysService.GetHolidaysByDate(date);
            //Assert
            iRepositoryHolidays.Verify(inv => inv.GetMany(d => (d.StartDay <= friday && d.EndDay >= monday && d.Name != Constants.FirstSemestrNameInDB && d.Name != Constants.SecondSemestrNameInDB)),Times.Once);
        }
        public void Holidays_RemoveUnitTest()
        {
            //Arrange
            var logger = new Mock<ILogger>();
            var iRepository = new Mock<IRepository<Holidays>>();
            var iUnitOfWork = new Mock<IUnitOfWork>();

            iUnitOfWork.SetupGet(u => u.HolidaysRepository).Returns(iRepository.Object);
            iRepository.Setup(h => h.Add(this.holidays));
            iRepository.Setup(h => h.GetById(this.holidays.Id));
            var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);
            //Act
            holidaysService.RemoveHolidays(this.holidays.Id);
            //Assert
            iRepository.Verify(inv => inv.Delete(It.IsAny<Holidays>()), Times.Once);
        }
 public void Holidays_Get_Test_If_Get_All_Holidays_And_Invoke_GetAll_repository_Method()
 {
     //Arange
     var logger = new Mock<ILogger>();
     var iUnitOfWork = new Mock<IUnitOfWork>();
     var iRepository = new Mock<IRepository<Holidays>>();
     iUnitOfWork.Setup(st => st.HolidaysRepository).Returns(iRepository.Object);
     var holidaysService = new HolidaysService(logger.Object, iUnitOfWork.Object);
     //Act
     holidaysService.GetAllHolidays();
     //Assert
     iRepository.Verify(inv => inv.GetAll(), Times.Once);
 }