public void J_EndWorkoutApiTest()
        {
            WorkoutCollection result;
            var           wc         = workoutService.GetWorkouts().Where(w => w.workout_title.Equals("TestApiWorkoutUpdated", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var           waRes      = workoutService.GetActiveWorkouts(wc.workout_id).FirstOrDefault();
            var           controller = new WorkoutTrackerController(workoutService, categoryService, _logManager);
            WorkoutActive wa         = new WorkoutActive()
            {
                workout_id = wc.workout_id,
                sid        = waRes.sid,
                start_date = waRes.start_date,
                start_time = waRes.start_time,
                end_date   = DateTime.UtcNow.Date,
                end_time   = DateTime.UtcNow.TimeOfDay,
                status     = true,
                comment    = "Ended"
            };

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            controller.Request.Headers.Add("Accept", "application/json");
            var response = controller.EndWorkout(wa);

            result = response.Content.ReadAsAsync <WorkoutCollection>().Result;
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreNotEqual(null, result);
            Assert.AreNotEqual(null, result.workout_active);
            Assert.AreNotEqual(0, result.workout_active.Count());
            Assert.AreNotEqual(null, result.workout_active.FirstOrDefault().end_date);
            Assert.AreNotEqual(null, result.workout_active.FirstOrDefault().end_time);
            Assert.AreEqual(true, result.workout_active.FirstOrDefault().status);
            Assert.AreNotEqual(null, result.workout_active.FirstOrDefault().comment);
            response.Dispose();
        }
        public void B_StartWorkoutTest()
        {
            int wId = workoutCollectionService.GetWorkouts().Where(x => x.workout_title.Equals("TestServiceWorkout", StringComparison.InvariantCultureIgnoreCase))
                      .FirstOrDefault().workout_id;
            workout_active wa = new workout_active()
            {
                workout_id = wId,
                start_date = DateTime.UtcNow.Date,
                start_time = DateTime.UtcNow.TimeOfDay,
                status     = false
            };

            workoutCollectionService.StartWorkout(wa);
            var result = workoutCollectionService.GetActiveWorkouts(wId).ToList();

            Assert.AreNotEqual(null, result);
            Assert.AreNotEqual(0, result.Count());
            Assert.AreEqual(false, wa.status);
            Assert.AreEqual(null, wa.comment);
            Assert.AreNotEqual(null, wa.start_date);
            Assert.AreNotEqual(null, wa.start_time);
            Assert.AreEqual(null, wa.end_date);
            Assert.AreEqual(null, wa.end_time);
        }
        public HttpResponseMessage GetActiveWorkout(WorkoutCollection wc)
        {
            WorkoutActive result = new WorkoutActive();

            try
            {
                var res = _workoutService.GetActiveWorkouts(wc.workout_id);
                MapActive(res.FirstOrDefault(), ref result);
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }