public void Delete_Old_Test()
        {
            var database = new Mock<IDatabaseService>();

            var fitocracy = new Mock<IFitocracyService>();
            fitocracy.Setup(x => x.GetWorkouts(0, 0)).Returns(Task.FromResult<IList<Workout>>(new Workout[0]));

            var activityGrouping = new Mock<IActivityGroupingService>();

            var workouts = new WorkoutPullService(database.Object, fitocracy.Object, activityGrouping.Object).Pull(new User()).Result;

            Assert.That(workouts, Is.Empty);
            database.Verify(x => x.DeleteWorkoutsBefore(0, DateTime.MaxValue));
            database.Verify(x => x.Insert(It.IsAny<Workout>()), Times.Never);
            database.Verify(x => x.Update(It.IsAny<Workout>(), It.IsAny<bool>()), Times.Never);
            database.Verify(x => x.Delete(It.IsAny<Workout>()), Times.Never);
        }
        public void Duplicate_Across_Pages_Test()
        {
            var database = new Mock<IDatabaseService>();
            database.Setup(x => x.GetWorkouts(0, new DateTime(2014, 1, 1), DateTime.MaxValue)).Returns(Task.FromResult<IEnumerable<Workout>>(new Workout[0]));

            var fitocracy = new Mock<IFitocracyService>();
            var workout2 = new Workout {Id = 2, Date = new DateTime(2014, 1, 2), Activities = new Activity[0]};
            var workout1 = new Workout {Id = 1, Date = new DateTime(2014, 1, 1), Activities = new Activity[0]};
            fitocracy.Setup(x => x.GetWorkouts(0, 0)).Returns(Task.FromResult<IList<Workout>>(new[] {workout2}));
            fitocracy.Setup(x => x.GetWorkouts(0, 1)).Returns(Task.FromResult<IList<Workout>>(new[] {workout2, workout1}));
            fitocracy.Setup(x => x.GetWorkouts(0, 3)).Returns(Task.FromResult<IList<Workout>>(new Workout[0]));

            var activityGrouping = new Mock<IActivityGroupingService>();

            var workouts = new WorkoutPullService(database.Object, fitocracy.Object, activityGrouping.Object).Pull(new User()).Result;

            Assert.That(workouts, Is.EqualTo(new[] {workout1, workout2}));
            database.Verify(x => x.Insert(workout1));
            database.Verify(x => x.Insert(workout2));
            database.Verify(x => x.Update(It.IsAny<Workout>(), It.IsAny<bool>()), Times.Never);
            database.Verify(x => x.Delete(It.IsAny<Workout>()), Times.Never);
        }
        public void Single_Update_Shallow_Test()
        {
            var database = new Mock<IDatabaseService>();
            var workout1 = new Workout {Id = 1, Date = new DateTime(2014, 1, 1), Points = 1, Activities = new Activity[0]};
            database.Setup(x => x.GetWorkouts(0, new DateTime(2014, 1, 1), DateTime.MaxValue)).Returns(Task.FromResult<IEnumerable<Workout>>(new[] {workout1}));

            var fitocracy = new Mock<IFitocracyService>();
            var workout1A = new Workout {Id = 1, Date = new DateTime(2014, 1, 1), Points = 2, Activities = new Activity[0]};
            fitocracy.Setup(x => x.GetWorkouts(0, 0)).Returns(Task.FromResult<IList<Workout>>(new[] {workout1A}));
            fitocracy.Setup(x => x.GetWorkouts(0, 1)).Returns(Task.FromResult<IList<Workout>>(new Workout[0]));

            var activityGrouping = new Mock<IActivityGroupingService>();

            var workouts = new WorkoutPullService(database.Object, fitocracy.Object, activityGrouping.Object).Pull(new User()).Result;

            Assert.That(workouts, Is.EqualTo(new[] {workout1A}));
            database.Verify(x => x.Update(workout1A, false));
            database.Verify(x => x.Insert(It.IsAny<Workout>()), Times.Never);
            database.Verify(x => x.Delete(It.IsAny<Workout>()), Times.Never);
        }
        public void Empty_Test()
        {
            var database = new Mock<IDatabaseService>();

            var fitocracy = new Mock<IFitocracyService>();
            fitocracy.Setup(x => x.GetWorkouts(0, 0)).Returns(Task.FromResult<IList<Workout>>(new Workout[0]));

            var activityGrouping = new Mock<IActivityGroupingService>();

            var workouts = new WorkoutPullService(database.Object, fitocracy.Object, activityGrouping.Object).Pull(new User()).Result;

            Assert.That(workouts, Is.Empty);
        }