예제 #1
0
        public void IfNoOpenSessionExistsNullIsReturned()
        {
            var repo = new Mock<IWorkoutRepository>();
            var service = new WorkoutService(repo.Object, null);
            repo.Setup(x => x.Where(It.IsAny<OpenWorkoutQuery>())).Returns(It.Is<IList<Workout>>(null));

            var currentWorkout = service.CurrentWorkout();

            currentWorkout.ShouldBeNull();
            repo.VerifyAll();
        }
예제 #2
0
        public void IfAnOpenSessionExistsThenItIsReturned()
        {
            var repo = new Mock<IWorkoutRepository>();
            var service = new WorkoutService(repo.Object, null);
            var workDoc = new List<Workout> { new Workout(new WorkoutDocument { Id = 1 }) };
            repo.Setup(x => x.Where(It.IsAny<OpenWorkoutQuery>())).Returns(workDoc);

            var currentWorkout = service.CurrentWorkout();

            currentWorkout.WorkoutId.ShouldEqual(1);
            repo.VerifyAll();
        }
예제 #3
0
        public void WhenCreatingANewWorkoutTheStartDateIsSet()
        {
            var invoker = new Mock<ICommandInvoker>();
            var service = new WorkoutService(null, invoker.Object);

            service.BeginNew();

            invoker.Verify(x => x.Execute(It.IsAny<BeginWorkoutCommand>()), Times.Once());

            //var workDoc = new List<Workout> { new Workout(new WorkoutDocument { Id = "wk/1" }) };
            //repo.Setup(x => x.Where(It.IsAny<OpenWorkoutQuery>())).Returns(workDoc);

            //var currentWorkout = service.CurrentWorkout();

            //currentWorkout.WorkoutId.ShouldEqual("wk/1");
            //repo.VerifyAll();
        }