Ejemplo n.º 1
0
        public void UpdateWorkout_ValidWorkout_ReturnsTrue()
        {
            IHttpActionResult actionResult = _workoutController.Get();
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <WorkoutDTO> >;

            if (contentResult != null)
            {
                var workout = contentResult.Content.FirstOrDefault();
                workout.WorkoutTitle = String.Format("Updated Workout Title {0}", new Random().Next());

                IHttpActionResult updateActionResult = _workoutController.Put(workout.WorkoutId, workout);
                var updateContentResult = updateActionResult as OkNegotiatedContentResult <bool>;

                Assert.IsNotNull(contentResult);
                Assert.IsTrue(updateContentResult.Content);

                IHttpActionResult getActionResult = _workoutController.Get(workout.WorkoutId);
                var getContentResult = getActionResult as OkNegotiatedContentResult <WorkoutDTO>;

                Assert.IsNotNull(getContentResult);
                Assert.AreEqual(workout.WorkoutTitle, getContentResult.Content.WorkoutTitle);
            }
        }