Пример #1
0
        public void GetAnswerById_InvalidArgument(int answerId)
        {
            // Arrange
            SOVAContext      databaseContext  = new SOVAContext(_connectionString);
            AnswerRepository answerRepository = new AnswerRepository(databaseContext);

            // Act
            Answer answer = answerRepository.GetAnswerById(answerId);

            // Assert
            Assert.Null(answer);
        }
Пример #2
0
        public IActionResult GetAnswerById(int id)
        {
            Answer answer = answerRepository.GetAnswerById(id);

            if (answer == null)
            {
                return(NotFound("Answer doesn't exist"));
            }
            AnswerViewModel ansVm = this.entityToVmMapper.Map(answer);

            return(Ok(ansVm));
        }
Пример #3
0
        public void GetAnswerById_IncludesSubmissions()
        {
            // Arrange
            SOVAContext      databaseContext  = new SOVAContext(_connectionString);
            AnswerRepository answerRepository = new AnswerRepository(databaseContext);

            int answerId = 106266;

            // Act
            Answer answer = answerRepository.GetAnswerById(answerId);

            // Assert
            Assert.NotNull(answer.Submission);
        }
Пример #4
0
        public void GetAnswerById_ValidArgument()
        {
            // Arrange
            SOVAContext      databaseContext  = new SOVAContext(_connectionString);
            AnswerRepository answerRepository = new AnswerRepository(databaseContext);

            int answerId = 106266;

            // Act
            Answer answer = answerRepository.GetAnswerById(answerId);

            // Assert
            Assert.Equal(answerId, answer.SubmissionId);
        }