Exemplo n.º 1
0
        public void GetById_ShouldCallWeekSchedulesRepoAllPropertyOnce()
        {
            var weekScheduleStub     = new Mock <IEfRepostory <WeekSchedule> >();
            var unitOfWorkStub       = new Mock <IUnitOfWork>();
            var datetimeProviderStub = new Mock <IDatetimeProvider>();

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

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

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

            var result = sut.GetById(id);

            weekScheduleStub.Verify(x => x.All, Times.Once);
        }
Exemplo n.º 2
0
        public void GetById_ShouldReturnCorrectEntryWhenIdMatchesThePasedId()
        {
            var weekScheduleStub     = new Mock <IEfRepostory <WeekSchedule> >();
            var unitOfWorkStub       = new Mock <IUnitOfWork>();
            var datetimeProviderStub = new Mock <IDatetimeProvider>();

            var list         = new List <WeekSchedule>();
            var weekSchedule = new WeekSchedule();

            list.Add(weekSchedule);

            var dbSetStub = list.AsQueryable();

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

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

            var result = sut.GetById(weekSchedule.Id);

            Assert.IsNotNull(result);
            Assert.IsInstanceOf <WeekSchedule>(result);
            Assert.AreSame(result, weekSchedule);
        }
Exemplo n.º 3
0
        public void GetById_ShouldReturnNullWhenNoEntryMatchesTheId()
        {
            var weekScheduleStub     = new Mock <IEfRepostory <WeekSchedule> >();
            var unitOfWorkStub       = new Mock <IUnitOfWork>();
            var datetimeProviderStub = new Mock <IDatetimeProvider>();

            var list         = new List <WeekSchedule>();
            var weekSchedule = new WeekSchedule();

            list.Add(weekSchedule);

            var dbSetStub = list.AsQueryable();

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

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

            var newId = new Guid();

            var result = sut.GetById(newId);

            Assert.IsNull(result);
        }