Esempio n. 1
0
        public void AddDailiesToSchedule_ShouldThrowwhenInvalidScheduleIsPassed()
        {
            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);

            Assert.Throws <ArgumentException>(() => sut.AddDailiesToSchedule(null));
        }
Esempio n. 2
0
        public void AddDailiesToSchedule_ShouldNotAddAnythingWhenNoWorkoutsAreProvided()
        {
            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);

            var schedule = new WeekSchedule();

            weekScheduleStub.Setup(x => x.Update(It.IsAny <WeekSchedule>()));
            unitOfWorkStub.Setup(x => x.Commit());

            sut.AddDailiesToSchedule(schedule);

            Assert.AreEqual(0, schedule.DailyWorkouts.Count);
        }
Esempio n. 3
0
        public void AddDailiesToSchedule_ShouldCallCommitOnTheUnitOfWork()
        {
            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);

            var schedule   = new WeekSchedule();
            var workoutOne = new DailyWorkout();
            var workoutTwo = new DailyWorkout();

            weekScheduleStub.Setup(x => x.Update(It.IsAny <WeekSchedule>()));
            unitOfWorkStub.Setup(x => x.Commit());

            sut.AddDailiesToSchedule(schedule, workoutOne, workoutTwo);

            unitOfWorkStub.Verify(x => x.Commit(), Times.Once);
        }