public void Update_ShouldThrowWhenInvalidWeekScheduleIsPassed() { var weekScheduleStub = new Mock <IEfRepostory <WeekSchedule> >(); var unitOfWorkStub = new Mock <IUnitOfWork>(); var datetimeProviderStub = new Mock <IDatetimeProvider>(); var sut = new WeekScheduleService(weekScheduleStub.Object, unitOfWorkStub.Object, datetimeProviderStub.Object); weekScheduleStub.Setup(x => x.Update(It.IsAny <WeekSchedule>())); unitOfWorkStub.Setup(x => x.Commit()); Assert.Throws <ArgumentException>(() => sut.Update(null)); }
public void Update_ShouldCallUnitOfWorkCommitOnce() { var weekScheduleStub = new Mock <IEfRepostory <WeekSchedule> >(); var unitOfWorkStub = new Mock <IUnitOfWork>(); var datetimeProviderStub = new Mock <IDatetimeProvider>(); var sut = new WeekScheduleService(weekScheduleStub.Object, unitOfWorkStub.Object, datetimeProviderStub.Object); weekScheduleStub.Setup(x => x.Update(It.IsAny <WeekSchedule>())); unitOfWorkStub.Setup(x => x.Commit()); var weekSchedule = new WeekSchedule(); sut.Update(weekSchedule); unitOfWorkStub.Verify(x => x.Commit(), Times.Once); }