Exemplo n.º 1
0
        //methods
        public void AddExercise(ExerciseDTO exercise)
        {
            IExerciseDAL dal           = ExerciseDALFactory.GetExerciseDAL();
            ExerciseDTO  exerciseToAdd = new ExerciseDTO(Guid.NewGuid(), exercise.Name, exercise.UserID, exercise.ExerciseType);

            dal.AddExercise(exerciseToAdd);
        }
Exemplo n.º 2
0
        public ExerciseDTO GetExercise(string exerciseID)
        {
            IExerciseDAL dal      = ExerciseDALFactory.GetExerciseDAL();
            ExerciseDTO  exercise = dal.GetExerciseDTO(exerciseID);

            return(exercise);
        }
        public ExerciseDTO GetExercise(string exerciseName)
        {
            IExerciseDAL exerciseDAL = ExerciseDALFactory.GetExerciseDAL();
            ExerciseDTO  exercise    = exerciseDAL.GetExerciseDTOByName(exerciseName);

            return(exercise);
        }
        public void Gets_two_exercises_successfully()
        {
            // Arrange
            IUser           user           = UserFactory.GetUser();
            IExerciseDAL    dal            = ExerciseDALFactory.GetExerciseDAL();
            IUserCollection userCollection = UserCollectionFactory.GetUserCollection();
            ExerciseDTO     legextension   = new ExerciseDTO(Guid.NewGuid(), "TempLegExtension", userID, ExerciseTypeDTO.Weighted);
            ExerciseDTO     pushup         = new ExerciseDTO(Guid.NewGuid(), "TempPushup", userID, ExerciseTypeDTO.Bodyweight);

            dal.AddExercise(legextension);
            dal.AddExercise(pushup);

            // Act
            ExerciseDTO legextensionDTO = userCollection.GetExercise("TempLegextension");
            ExerciseDTO pushupDTO       = userCollection.GetExercise("TempPushup");


            // Assert
            Assert.AreEqual(userID, legextensionDTO.UserID);
            Assert.AreEqual(ExerciseTypeDTO.Weighted, legextensionDTO.ExerciseType);
            Assert.AreEqual("TempLegextension", legextensionDTO.Name);
            Assert.AreEqual(legextension.ExerciseID, legextensionDTO.ExerciseID);

            Assert.AreEqual(userID, pushupDTO.UserID);
            Assert.AreEqual(ExerciseTypeDTO.Bodyweight, pushupDTO.ExerciseType);
            Assert.AreEqual("TempPushup", pushupDTO.Name);
            Assert.AreEqual(pushup.ExerciseID, pushupDTO.ExerciseID);
        }
Exemplo n.º 5
0
        private RoundDTO ConvertRound(Round round)
        {
            List <SetDTO> setDTOs = new List <SetDTO>();

            foreach (var set in round.GetSets())
            {
                setDTOs.Add(ConvertSet(set));
            }
            IExerciseDAL dal      = ExerciseDALFactory.GetExerciseDAL();
            RoundDTO     roundDTO = new RoundDTO(
                dal.GetExerciseDTO(round.ExerciseID.ToString()),
                round.RoundID,
                round.TrainingID,
                round.ExerciseID,
                setDTOs);

            return(roundDTO);
        }
        public void Get_Exercise_By_ID()
        {
            //arrange
            IUser        user         = UserFactory.GetUser();
            IExerciseDAL dal          = ExerciseDALFactory.GetExerciseDAL();
            ExerciseDTO  tempExercise = new ExerciseDTO(Guid.NewGuid(), "TempSquat", userID, ExerciseTypeDTO.Weighted);

            dal.AddExercise(tempExercise);

            //act
            ExerciseDTO exerciseDTO = user.GetExercise(tempExercise.ExerciseID.ToString());

            //assert
            Assert.AreEqual("TempSquat", exerciseDTO.Name);
            Assert.AreEqual(tempExercise.ExerciseID, exerciseDTO.ExerciseID);
            Assert.AreEqual(ExerciseTypeDTO.Weighted, exerciseDTO.ExerciseType);
            Assert.AreEqual(userID, exerciseDTO.UserID);
        }
Exemplo n.º 7
0
        private Round ConvertRoundDTO(RoundDTO roundDTO)
        {
            List <Set> sets = new List <Set>();

            foreach (var setDTO in roundDTO.GetSets())
            {
                sets.Add(ConvertSetDTO(setDTO));
            }
            IExerciseDAL dal   = ExerciseDALFactory.GetExerciseDAL();
            Round        round = new Round(
                ConvertExerciseDTO(dal.GetExerciseDTO(roundDTO.ExerciseID.ToString())),
                sets,
                roundDTO.RoundID,
                roundDTO.TrainingID,
                roundDTO.ExerciseID
                );

            return(round);
        }
        public void Get_Exercise_By_Name()
        {
            //arrange
            IUserCollection userCollection = UserCollectionFactory.GetUserCollection();
            IExerciseDAL    dal            = ExerciseDALFactory.GetExerciseDAL();
            Guid            exerciseID     = Guid.NewGuid();
            ExerciseDTO     tempExercise   = new ExerciseDTO(exerciseID, "TempDeadlift", userID, ExerciseTypeDTO.Weighted);

            dal.AddExercise(tempExercise);

            //act
            ExerciseDTO TempDeadliftDTO = userCollection.GetExercise("TempDeadlift");

            //assert
            Assert.AreEqual("TempDeadlift", TempDeadliftDTO.Name);
            Assert.AreEqual(exerciseID, TempDeadliftDTO.ExerciseID);
            Assert.AreEqual(ExerciseTypeDTO.Weighted, TempDeadliftDTO.ExerciseType);
            Assert.AreEqual(userID, TempDeadliftDTO.UserID);
        }
        public void DeleteExercise(string exerciseID)
        {
            IExerciseDAL dal = ExerciseDALFactory.GetExerciseDAL();

            dal.DeleteExercise(exerciseID);
        }
Exemplo n.º 10
0
        public ExerciseDTO GetExerciseByName(string exerciseName)
        {
            IExerciseDAL dal = ExerciseDALFactory.GetExerciseDAL();

            return(dal.GetExerciseDTOByName(exerciseName));
        }
Exemplo n.º 11
0
        //methods
        public bool ExerciseExists(string exerciseName)
        {
            IExerciseDAL dal = ExerciseDALFactory.GetExerciseDAL();

            return(dal.ExerciseExists(exerciseName));
        }