Пример #1
0
        public void GetCurrentSchedule_ShouldCallWeekScheduleRepoAllPropertyOnce()
        {
            var weekScheduleStub     = new Mock <IEfRepostory <WeekSchedule> >();
            var unitOfWorkStub       = new Mock <IUnitOfWork>();
            var datetimeProviderStub = new Mock <IDatetimeProvider>();

            var dbSetStub = new List <WeekSchedule>().AsQueryable();

            var sut = new WeekScheduleService(weekScheduleStub.Object, unitOfWorkStub.Object, datetimeProviderStub.Object);

            weekScheduleStub.Setup(x => x.All).Returns(dbSetStub);

            var result = sut.GetCurrentSchedule();

            weekScheduleStub.Verify(x => x.All, Times.Once);
        }
Пример #2
0
        public void GetCurrentSchedule_ShouldReturnCorrectSchedule()
        {
            var weekScheduleStub     = new Mock <IEfRepostory <WeekSchedule> >();
            var unitOfWorkStub       = new Mock <IUnitOfWork>();
            var datetimeProviderStub = new Mock <IDatetimeProvider>();

            var today = new DateTime(2017, 10, 5);

            var list = new List <WeekSchedule>();

            var weekScheduleOne = new WeekSchedule
            {
                WeekStart = new DateTime(2017, 10, 2),
                WeekEnd   = new DateTime(2017, 10, 8)
            };

            var weekScheduleTwo = new WeekSchedule
            {
                WeekStart = new DateTime(2017, 10, 9),
                WeekEnd   = new DateTime(2017, 10, 15)
            };

            list.Add(weekScheduleOne);
            list.Add(weekScheduleTwo);

            var dbSetStub = list.AsQueryable();

            var sut = new WeekScheduleService(weekScheduleStub.Object, unitOfWorkStub.Object, datetimeProviderStub.Object);

            weekScheduleStub.Setup(x => x.All).Returns(dbSetStub);
            datetimeProviderStub.Setup(x => x.GetToday()).Returns(today);

            var result = sut.GetCurrentSchedule();

            Assert.AreSame(weekScheduleOne, result);
        }