コード例 #1
0
        public void Initialize()
        {
            DbContextHelpers contextHelpers = new DbContextHelpers();
            search = new WorkoutSearch();

            db = contextHelpers.getDbContext();
            controller = new HomeController(db.Object) {
                ControllerContext = MockContext.AuthenticationContext("jjones")
            };
            controller.pageSize = 10;
        }
コード例 #2
0
 public void TestHomeControllerCreateNewWorkoutWithNoUserError()
 {
     controller = new HomeController(db.Object)
     {
         ControllerContext = MockContext.AuthenticationContext("not_a_real_user")
     };
     var workout = new workout();
     var workoutExercise = new workout_exercise();
     workout.workout_exercise.Add(workoutExercise);
     ViewResult result = controller.New(workout) 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 workout being created", model.StatusDescription);
 }