public void TestWorkoutRatingAddRatingToNonExistingWorkout() { ViewResult result = controller.AddWorkoutRating(55, 8) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual("DetailedError", result.ViewName); Assert.IsInstanceOfType(result.Model, typeof(HttpStatusCodeResult)); var model = result.Model as HttpStatusCodeResult; Assert.AreEqual(500, model.StatusCode); Assert.AreEqual("Failed to rate the requested workout.", model.StatusDescription); }
public void TestWorkoutRatingAddRatingWithNoUserError() { controller = new WorkoutRatingController(db.Object) { ControllerContext = MockContext.AuthenticationContext("not_a_real_user") }; ViewResult result = controller.AddWorkoutRating(28, 10) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual("DetailedError", result.ViewName); Assert.IsInstanceOfType(result.Model, typeof(HttpStatusCodeResult)); var model = result.Model as HttpStatusCodeResult; Assert.AreEqual(500, model.StatusCode); Assert.AreEqual("No user could be associated with the rating being added", model.StatusDescription); }