Example #1
0
        public MockAnswerRepository()
        {
            _context = new List <Answer>();

            for (int i = 0; i < 2; i++)
            {
                var answer = GetFakeQuiz.Answer(i + 1, i == 0?true:false);
                _context.Add(answer);
            }
        }
Example #2
0
        public void CreateQuestionAnswer()
        {
            // Act
            var id     = 942;
            var answer = GetFakeQuiz.Answer(id, true);

            // Assert
            var result = _service.CreateQuestionAnswer(answer);

            // Assert
            Assert.IsTrue(result.IsOK);
            var createdAnswer = _service.GetQuestionAnswer(id).GetData();

            Assert.IsNotNull(createdAnswer);
            Assert.IsTrue(createdAnswer.Id == id);
        }
Example #3
0
        public void Create()
        {
            // Arrange
            var id        = 888;
            var isCorrect = true;
            var item      = GetFakeQuiz.Answer(id, isCorrect);

            // Act
            var result = repository.CreateItem(item);

            // Assert
            Assert.IsTrue(result);
            var insertedItem = repository.GetItem(id);

            Assert.IsTrue(insertedItem.Id == id);
            Assert.IsTrue(insertedItem.AnswertText == "AnswerText" + id);
            Assert.IsTrue(insertedItem.isCorrectAnswer == isCorrect);
            var items = repository.GetAllItems();

            Assert.IsTrue(items.Count() == ITEMS_COUNT + 1);
        }