public void CreateExercise_UserIdHasValue_ReturnsUserIdThatWasGiven()
        {
            // Arrange
            var UserId  = NextId;
            var request = new ExerciseCreateDto {
                UserId = UserId
            };

            // Act
            var repo   = new ExerciseRepository(Context);
            var result = repo.CreateExercise(request);

            // Assert
            Assert.AreEqual(UserId, result.UserId);
        }
        public void CreateExercise_NameHasValue_ReturnsNameThatWasGiven()
        {
            // Arrange
            var name    = $"{NextId}";
            var request = new ExerciseCreateDto {
                Name = name
            };

            // Act
            var repo   = new ExerciseRepository(Context);
            var result = repo.CreateExercise(request);

            // Assert
            Assert.AreEqual(name, result.Name);
        }
        public void CreateExercise_MuscleGroupHasValue_ContextHasNewExerciseWithCorrectMuscleGroup()
        {
            // Arrange
            var muscleGroup = $"{NextId}";
            var request     = new ExerciseCreateDto {
                MuscleGroup = muscleGroup
            };

            // Act
            var repo   = new ExerciseRepository(Context);
            var result = repo.CreateExercise(request);
            var exerciseFromContext = Context.Exercises.Find(result.Id);

            // Assert
            Assert.AreEqual(muscleGroup, exerciseFromContext.MuscleGroup);
        }
        public void CreateExercise_NameHasValue_ContextHasNewExerciseWithCorrectName()
        {
            // Arrange
            var name    = $"{NextId}";
            var request = new ExerciseCreateDto {
                Name = name
            };

            // Act
            var repo   = new ExerciseRepository(Context);
            var result = repo.CreateExercise(request);
            var exerciseFromContext = Context.Exercises.Find(result.Id);

            // Assert
            Assert.AreEqual(name, exerciseFromContext.Name);
        }
        public void CreateExercise_UserIdHasValue_ContextHasNewExerciseWithCorrectUserId()
        {
            // Arrange
            var UserId  = NextId;
            var request = new ExerciseCreateDto {
                UserId = UserId
            };

            // Act
            var repo   = new ExerciseRepository(Context);
            var result = repo.CreateExercise(request);
            var exerciseFromContext = Context.Exercises.Find(result.Id);

            // Assert
            Assert.AreEqual(UserId, exerciseFromContext.UserId);
        }
Beispiel #6
0
        public void CreateExercisesForNewLesson(lesson lesson)
        {
            int lessonSetupId = _lessonsSetupRepository.GetLessonSetupIdByLessonNumber(lesson.lesson_number);

            foreach (var exerciseSetup in _exercisesSetupRepository.GetExercisesSetupByLessonSetupId(lessonSetupId))
            {
                var exercise = new exercis
                {
                    exercise_number = exerciseSetup.exercise_number,
                    lesson_id       = lesson.id,
                    is_done         = false
                };

                _exerciseRepository.CreateExercise(exercise);
            }
        }
        public ActionResult Create([FromForm] Exercise model)
        {
            var exercise = ExerciseRepository.CreateExercise(model);

            return(RedirectToAction(nameof(Index)));
        }