public void AddQuestionCheck()
        {
            var question = new Question { Difficulty = Difficulty.Difficult, Rating = 5 };
            _mockRepository.Setup(_ => _.Add(question)).Returns(question);
            var result = _service.AddQuestion(question);

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Rating);
        }
示例#2
0
        public void Initialize()
        {
            MockRepository = new Mock<IRepository<Test>>();

            var firstQuestion = new Question { QuestionId = 1, Difficulty = Difficulty.Hard, Rating = 5 };
            var secondQuestion = new Question { QuestionId = 2, Difficulty = Difficulty.Hard, Rating = 3 };
            var brief = new Brief { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Answer = "It wasn't me" };
            var choice = new Choice { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Choices = "Me,You,All of us all are the culprits", Answers = "Me", IsMultiplechoice = true };

            _questions = new List<Question> { firstQuestion, secondQuestion, brief, choice };
            _user = new UserDetail { Name = "Ashutosh", Password = "******", UserRole = UserRole.Admin, DateOfCreation = DateTime.UtcNow };
            _subject = new Subject { SubjectName = "Mathematics", SubjectCategory = "Advanced" };
            _tests = new List<Test>
                                    {
                                      new Test
                                                {
                                                    TestId = 1,
                                                    DateOfCreation = DateTime.UtcNow,
                                                    Subject = _subject,
                                                    Creator = _user,
                                                    Questions = _questions
                                                },
                                      new Test
                                                {
                                                    TestId = 2,
                                                    DateOfCreation = DateTime.UtcNow,
                                                    Subject = _subject,
                                                    Creator = _user,
                                                    Questions = _questions
                                                }
                                    };
            MockRepository.Setup(_ => _.Query()).Returns(_tests.AsQueryable());
            _test = new Test
                            {
                               TestId = 3,
                               DateOfCreation = DateTime.UtcNow,
                               Subject = _subject,
                               Creator = _user,
                               Questions = _questions
                            };
            MockRepository.Setup(_ => _.Add(_test)).Returns(_test);
            _repository = MockRepository.Object;
            _service = new TestService(_repository, _unitOfWork);
            MockRepository.Setup(_ => _.Query()).Returns(_tests.AsQueryable());
        }
示例#3
0
 /// <summary>
 /// Adds a Question
 /// </summary>
 /// <param name="question">Question to be Added</param>
 /// <returns>The Added question</returns>
 public Question AddQuestion(Question question)
 {
     return _questionRepository.Add(question);
 }
示例#4
0
 /// <summary>
 /// Removes a Question
 /// </summary>
 /// <param name="question">Question to Remove</param>
 /// <returns>The question removed</returns>
 public Question RemoveQuestion(Question question)
 {
     return _questionRepository.Remove(question);
 }
        public void Initialize()
        {
            _mockRepository = new Mock<IRepository<Question>>();
            var firstQuestion = new Question { QuestionId = 1, Difficulty = Difficulty.Hard, Rating = 5 };
            var secondQuestion = new Question { QuestionId = 2, Difficulty = Difficulty.Hard, Rating = 3 };
            var brief = new Brief { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Answer = "It wasn't me" };
            var choice = new Choice { Difficulty = Difficulty.Hard, Rating = 5, QuestionText = "Who let the dog's out ?", Choices = "Me,You,All of us all are the culprits", Answers = "All of us all are the culprits", IsMultiplechoice = true };
            _questions = new List<Question> { firstQuestion, secondQuestion, brief, choice };

            _mockRepository.Setup(_ => _.Query()).Returns(_questions.AsQueryable());

            _repository = _mockRepository.Object;
            _service = new QuestionService(_repository, _unitOfWork);
        }