public void Remove(Guid id)
        {
            // 2
            Homework homework = homeworksRepository.Get(id);

            if (homework == null)
            {
                throw new ArgumentException("Invalid guid");
            }
            homeworksRepository.Remove(homework);
            homeworksRepository.Save();
        }
        public Exercise AddExercise(Guid id, Exercise exercise)
        {
            Homework homework = homeworksRepository.Get(id);

            if (homework == null)
            {
                throw new ArgumentException("Invalid guid");
            }
            homework.Exercises.Add(exercise);
            homeworksRepository.Update(homework);
            homeworksRepository.Save();
            return(exercise);
        }
예제 #3
0
        public void Remove(Guid id)
        {
            //2
            Homework homework = homeworksRepository.Get(id);

            if (homework == null)
            {
                //TODO: ¿Se pueden manejar mejor los mensaje de las excepciones?
                throw new ArgumentException("Invalid guid");
            }
            homeworksRepository.Remove(homework);
            //nunca olvidar esto !
            homeworksRepository.Save();
        }
예제 #4
0
        public void Update()
        {
            // arrange
            var fixture           = new Fixture();
            var HomeworkExistUser = 490;
            var updatedhomework   = fixture.Build <Homework>().Create();

            updatedhomework.TopicId = 1;
            updatedhomework.Id      = HomeworkExistUser;

            // act
            _repository.Update(updatedhomework);

            // assert
            var homework = _repository.Get(HomeworkExistUser);

            Assert.NotNull(homework);
            Assert.AreEqual(updatedhomework.TopicId, homework.TopicId);
            Assert.AreEqual(updatedhomework.Name, homework.Name);
            Assert.AreEqual(updatedhomework.Link, homework.Link);
            Assert.AreEqual(updatedhomework.Grade, homework.Grade);
        }
예제 #5
0
        public async Task Update()
        {
            var fixture     = new Fixture();
            var newhomework = fixture.Create <Homework>();

            var homeworkId = await _repository.Add(newhomework);

            var updatedhomework = fixture.Create <Homework>();

            updatedhomework.Id = homeworkId;

            // act
            await _repository.Update(updatedhomework);

            // assert
            var homework = await _repository.Get(homeworkId);

            Assert.NotNull(homework);
            Assert.Equal(updatedhomework.Title, homework.Title);
            Assert.Equal(updatedhomework.Description, homework.Description);
            Assert.Equal(updatedhomework.Link, homework.Link);
        }