Ejemplo n.º 1
0
        public void AddQuestionBriefCheck()
        {
            var question = new Brief { Difficulty = Difficulty.Hard, Rating = 4, QuestionText = "Who let the dog's out ?", Answer = "It wasn't me" };
            _mockRepository.Setup(_ => _.Add(question)).Returns(question);
            var result = _service.AddQuestion(question);

            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Rating);
        }
Ejemplo n.º 2
0
            public void Update()
            {
                var questionToAdd = new Brief
                                                {
                                                    QuestionText = "I am a brief question",
                                                    Rating = 4,
                                                    Short = true,
                                                    Difficulty = Difficulty.Hard,
                                                    Answer = "No real question",
                                                    Creator = User,
                                                    Subject = Subject,
                                                    DateOfCreation = DateTime.UtcNow
                                                };
                    QuestionRepository.Add(questionToAdd);
                    EfUoW.Commit();

                    var question = QuestionRepository.Query().OfType<Brief>().Where(_ => _.Rating > 3).FirstOrDefault();
                    question.Answer = "I have changed the answer";
                    var result = QuestionRepository.Update(question);
                    EfUoW.Commit();

                    Assert.IsNotNull(result);
                    Assert.IsInstanceOf<Brief>(result);
                    Assert.AreEqual("I have changed the answer", (result as Brief).Answer);
            }
Ejemplo n.º 3
0
            public void Retrieve()
            {
                var questionToAdd = new Brief
                                                  {
                                                    QuestionText = "I am a brief question",
                                                    Rating = 4, Short = true,
                                                    Difficulty = Difficulty.Hard,
                                                    Answer = "No real question",
                                                    Creator = User,
                                                    Subject = Subject,
                                                    DateOfCreation = DateTime.UtcNow
                                                  };
                    QuestionRepository.Add(questionToAdd);
                    EfUoW.Commit();

                    var result = QuestionRepository.Query().OfType<Brief>().FirstOrDefault();
                    Assert.IsNotNull(result);
                    Assert.IsInstanceOf<Brief>(result);
                    Assert.AreEqual(true, result.Short);
            }
Ejemplo n.º 4
0
            public void Initialise()
            {
                BriefQuestionToBeCreated = new Brief
                {
                    QuestionText = "I am a brief question",
                    Rating = 4,
                    Short = true,
                    Difficulty = Difficulty.Hard,
                    Answer = "No real question",
                    Creator = User,
                    Subject = Subject,
                    DateOfCreation = DateTime.UtcNow
                };

                MatchQuestionToBeCreated = new Match
                {
                    QuestionText = "I am a brief question",
                    Rating = 4,
                    LeftChoices = "foo;baar;temp;help",
                    Difficulty = Difficulty.Hard,
                    RightChoices = "foo;baar;temp;help",
                    Creator = User,
                    Subject = Subject,
                    DateOfCreation = DateTime.UtcNow
                };
            }
Ejemplo n.º 5
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());
        }
Ejemplo n.º 6
0
        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);
        }