コード例 #1
0
        public void Should_Update_Existing_Exercise()
        {
            //ARRANGE
            var exerciseSvc = new Mock <IExerciseService>(MockBehavior.Strict);
            var exercise    = new Exercise();

            exerciseSvc
            .Setup(x => x.Update(It.IsAny <Exercise>(), true))
            .Returns((Exercise newExercise, bool save) => exercise);

            var sut = new ExerciseController(exerciseSvc.Object);

            SetupUser(sut);

            //ACT
            var response = sut.Put(exercise.Id, exercise);

            //ASSERT
            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response.Result, typeof(OkObjectResult));
            Assert.ReferenceEquals((response.Result as OkObjectResult).Value, exercise);
        }