Esempio n. 1
0
        public List <QuestionDTO> GetAll()
        {
            List <QuestionEntity> allquestions = ur.GetAll();
            List <QuestionDTO>    l1           = Mapper.Map <List <QuestionDTO> >(allquestions);

            return(l1);
        }
Esempio n. 2
0
        public void GetALlQuestions_Successful()
        {
            //ARRANGE
            var options = new DbContextOptionsBuilder <AskContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new AskContext(options);
            IQuestionRepository questionRepository = new QuestionRepository(context);

            DateTime date     = DateTime.Now;
            var      question = new QuestionTO {
                IsResolved = false, Message = "Je n'arrive pas à faire un test!", Title = "Problème avec Tests", Date = date, AuthorId = 1
            };
            var question2 = new QuestionTO {
                IsResolved = true, Message = "Comment créer un projet MVC 6?", Title = "MVC6", Date = date, AuthorId = 2
            };
            var question3 = new QuestionTO {
                IsResolved = false, Message = "Comment faire boucle foreach?", Title = "foreach", Date = date, AuthorId = 2
            };
            var addedQuestion  = questionRepository.Create(question);
            var addedQuestion2 = questionRepository.Create(question2);
            var addedQuestion3 = questionRepository.Create(question3);

            context.SaveChanges();

            //ACT
            var test = questionRepository.GetAll();

            //ASSERT
            Assert.AreEqual(3, test.Count());
        }
Esempio n. 3
0
        private void GetQuestions()
        {
            IEnumerable <Question>          questions  = QuestionRepository.GetAll();
            IEnumerable <QuestionViewModel> questionVM = questions
                                                         .Select(o => new QuestionViewModel(o));

            Questions = new ObservableCollection <QuestionViewModel>(questionVM);
            RaisePropertyChanged("Questions");
        }
Esempio n. 4
0
        public void GetAllTest()
        {
            var data = repository.GetAll();

            //Xunit.Assert.NotNull(data);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNotNull(data);

            //Xunit.Assert.True(data.Count() > 0);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(data.Count() > 0);
        }
Esempio n. 5
0
        public void GetAllQuestions_NoQuestionInDb_ThrowException()
        {
            var options = new DbContextOptionsBuilder <AskContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using var context = new AskContext(options);
            IQuestionRepository questionRepository = new QuestionRepository(context);

            Assert.ThrowsException <ArgumentNullException>(() => questionRepository.GetAll());
        }
        // GET: Home
        public ActionResult Quiz()
        {
            AppUserScore kullaniciScore = new AppUserScore();

            kullaniciScore.AppUser = Session["girisyapan"] as AppUser;

            if (kullaniciScore.Score != null)
            {
                ViewBag.testcozuldu = "Daha önce testi cozdunuz.";
            }

            return(View(qRep.GetAll()));
        }
Esempio n. 7
0
        public void GetAllQuestions_AddThreeNewQuestionsThenRetrieveAddedQuestions_ReturnCorrectNumberOfQuestions()
        {
            //ARRANGE
            var options    = new DbContextOptionsBuilder().UseInMemoryDatabase(MethodBase.GetCurrentMethod().Name).Options;
            var context    = new ApplicationContext(options);
            var repository = new QuestionRepository(context);
            var question1  = new Question
            {
                Message   = "Test question 1",
                PostDate  = DateTime.Now,
                State     = QuestionState.Waiting,
                IsDeleted = false,
                Requester = new ApplicationUser {
                    Id = "aaaaabbbbbcccccdddd", Email = "*****@*****.**"
                }
            };
            var question2 = new Question
            {
                Message   = "Test question 2",
                PostDate  = DateTime.Now,
                State     = QuestionState.Waiting,
                IsDeleted = false,
                Requester = new ApplicationUser {
                    Id = "bbbbbcccccddddeeeeee", Email = "*****@*****.**"
                }
            };
            var question3 = new Question
            {
                Message   = "Test question 3",
                PostDate  = DateTime.Now,
                State     = QuestionState.Waiting,
                IsDeleted = false,
                Requester = new ApplicationUser {
                    Id = "cccccbbbbbcccccdddd", Email = "*****@*****.**"
                }
            };
            var addedQuestion1 = repository.Insert(question1);
            var addedQuestion2 = repository.Insert(question2);
            var addedQuestion3 = repository.Insert(question3);

            context.SaveChanges();
            //ACT
            var result = repository.GetAll();

            //ASSERT
            Assert.IsNotNull(addedQuestion1);
            Assert.IsNotNull(addedQuestion2);
            Assert.IsNotNull(addedQuestion3);
            Assert.AreEqual(3, result.Count());
        }
        public void Question_GetAll()
        {
            var options = new DbContextOptionsBuilder <QAndAContext>().UseInMemoryDatabase(MethodBase.GetCurrentMethod().Name).Options;
            var context = new QAndAContext(options);
            IQuestionRepository QRepo = new QuestionRepository(context);

            var question1 = new QuestionTO
            {
                Questioning  = "Great Power Blah blah blah",
                CreationDate = DateTime.Now,
                State        = State.Resolved,
                IsArchived   = false,
                LostSoul     = new UserTO {
                    FirstName = "Peter", LastName = "Pan"
                }
            };
            var question2 = new QuestionTO
            {
                Questioning  = "How to cure RDR2",
                CreationDate = DateTime.Now,
                State        = State.Pending,
                IsArchived   = false,
                LostSoul     = new UserTO {
                    FirstName = "Arthur", LastName = "Morgan"
                }
            };
            var question3 = new QuestionTO
            {
                Questioning  = "Why no tracking ?",
                CreationDate = DateTime.Now,
                State        = State.Pending,
                IsArchived   = true,
                LostSoul     = new UserTO {
                    FirstName = "Pro", LastName = "Stalker"
                }
            };

            QRepo.Insert(question1);
            QRepo.Insert(question2);
            QRepo.Insert(question3);
            QRepo.Save();

            var result = QRepo.GetAll();

            Assert.AreEqual(2, result.Count());
        }
        public void GetAll_Questions_Success()
        {
            BitcoinShowDBContext context = DbContextFactory.GetContext();
            Option option = new Option
            {
                Text = "Option"
            };

            context.Options.Add(option);
            context.SaveChanges();
            List <Option> optionsList = new List <Option>();

            optionsList.Add(option);
            Question question = new Question
            {
                Title  = $"Random Question {1}",
                Answer = new Option {
                    Text = $"Random Option {1}"
                },
                Level = LevelEnum.Medium,
            };

            question.Options          = new List <Option>();
            optionsList[0].QuestionId = question.Id;
            question.Options.Add(optionsList[0]);
            context.Questions.Add(question);
            context.SaveChanges();

            QuestionRepository repository = new QuestionRepository(context);

            repository.GetAll().ForEach(q =>
            {
                Assert.NotNull(q);
                Assert.True(q.Id > 0);
                Assert.False(String.IsNullOrEmpty(q.Title));
                Assert.NotNull(q.Answer);
                Assert.True(q.Answer.Id > 0);
                Assert.False(String.IsNullOrEmpty(q.Answer.Text));
                Assert.Equal(q.Level, LevelEnum.Medium);
                Assert.Equal(optionsList, q.Options);
            });
        }
Esempio n. 10
0
        public ActionResult ListView()
        {
            try
            {
                var savedQuestions = _questionRepository.GetAll();

                foreach (var item in savedQuestions)
                {
                    item.SetTypeDesc(GetTypeDesc(item.Type));
                }

                ViewBag.Questions = savedQuestions;

                return(View());
            }
            catch (Exception ex)
            {
                return(View(ex.Message));
            }
        }
Esempio n. 11
0
 public IEnumerable <Question> GetQuestionsHistorybyExpertId(int id)
 {
     return(QuestionRepository.GetAll(t => t.ExpertId == id));
 }
 public List<Question> QuestionList()
 {
     return questionRepository.GetAll();
 }
Esempio n. 13
0
 public List <Question> GetAll()
 {
     return(questionRepository.GetAll());
 }
Esempio n. 14
0
        public IEnumerable <Question> GetAll()
        {
            var questions = QuestionRepository.GetAll();

            return(questions);
        }
Esempio n. 15
0
 public IEnumerable <Question> GetAll()
 {
     return(QuestionRepository.GetAll());
 }
Esempio n. 16
0
 public IEnumerable <Question> GetQuestionsbyUserId(int id)
 {
     return(QuestionRepository.GetAll(t => t.UserId == id && t.Active == true));
 }
Esempio n. 17
0
 public void GetAll_WillReturn_Records()
 {
     Assert.True(_db.GetAll().ToList().Count > 0);
 }
Esempio n. 18
0
 public IQueryable <Question> GetAllQuestions() => questionRepo.GetAll();
Esempio n. 19
0
 public IEnumerable <Question> GetQuestions()
 => _questionRepository.GetAll();
Esempio n. 20
0
 public IEnumerable <Question> GetQuestionsbyExpertId(int id)
 {
     return(QuestionRepository.GetAll(t => t.ExpertId == id && t.Active == true && t.ExpertReply == null));
 }
Esempio n. 21
0
 public IEnumerable <Question> GetAll()
 {
     return(questionRepo.GetAll());
 }
        public void AddFormReturnsCorrectNumberOfForm()
        {
            var options = new DbContextOptionsBuilder <EvaluationContext>()
                          .UseInMemoryDatabase(databaseName: MethodBase.GetCurrentMethod().Name)
                          .Options;

            using (var memoryContext = new EvaluationContext(options))
            {
                // Arrange
                IFormRepository                formRepository                = new FormRepository(memoryContext);
                IQuestionRepository            questionRepository            = new QuestionRepository(memoryContext);
                IQuestionPropositionRepository questionPropositionRepository = new QuestionPropositionRepository(memoryContext);

                #region Form

                var Form1 = new FormTO
                {
                    Name = new MultiLanguageString
                           (
                        "Daily evaluation form",
                        "Formulaire d'évaluation journalier",
                        "Dagelijks evaluatieformulier"
                           ),
                };

                var Form2 = new FormTO
                {
                    Name = new MultiLanguageString
                           (
                        "Daily evaluation form2",
                        "Formulaire d'évaluation journalier2",
                        "Dagelijks evaluatieformulier2"
                           ),
                };

                var Form3 = new FormTO
                {
                    Name = new MultiLanguageString
                           (
                        "Daily evaluation form3",
                        "Formulaire d'évaluation journalier3",
                        "Dagelijks evaluatieformulier3"
                           ),
                };
                var formAdded1 = formRepository.Add(Form1);
                var formAdded2 = formRepository.Add(Form2);
                var formAdded3 = formRepository.Add(Form3);
                memoryContext.SaveChanges();

                #endregion

                #region Questions

                var Question1 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 1,
                    Libelle  = new MultiLanguageString
                               (
                        "What is your general impression after this first day of training ?",
                        "Quelle est votre impression générale après cette première journée de formation ?",
                        "Wat is je algemene indruk na deze eerste dag van training ?"
                               ),
                    Type = QuestionType.SingleChoice,
                };

                var Question2 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 2,
                    Libelle  = new MultiLanguageString
                               (
                        "Is the pace right for you ?",
                        "Est-ce que le rythme vous convient ?",
                        "Is het tempo geschikt voor u ?"
                               ),
                    Type = QuestionType.SingleChoice,
                };

                var Question3 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 3,
                    Libelle  = new MultiLanguageString
                               (
                        "Do you have questions related to the subject studied today ?",
                        "Avez-vous des questions relatives à la matière étudiée aujourd’hui ?",
                        "Heb je vragen over het onderwerp dat vandaag is bestudeerd ?"
                               ),
                    Type = QuestionType.Open
                };

                var Question4 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 4,
                    Libelle  = new MultiLanguageString
                               (
                        "Do you have specific questions / particular topics that you would like deepen during this training ?",
                        "Avez-vous des questions spécifiques/sujets particuliers que vous aimeriez approfondir durant cette formation ?",
                        "Heeft u specifieke vragen / specifieke onderwerpen die u graag zou willen verdiepen tijdens deze training ?"
                               ),
                    Type = QuestionType.Open
                };

                var Question5 = new QuestionTO
                {
                    Form     = formAdded1,
                    Position = 5,
                    Libelle  = new MultiLanguageString
                               (
                        "What objectives do you pursue by following this training ?",
                        "Quels objectifs poursuivez-vous en suivant cette formation ?",
                        "Welke doelstellingen streeft u na door deze training te volgen?"
                               ),
                    Type = QuestionType.Open
                };

                var questionAdded1 = questionRepository.Add(Question1);
                var questionAdded2 = questionRepository.Add(Question2);
                var questionAdded3 = questionRepository.Add(Question3);
                var questionAdded4 = questionRepository.Add(Question4);
                var questionAdded5 = questionRepository.Add(Question5);
                memoryContext.SaveChanges();

                #endregion

                #region QuestionProposition
                var QuestionProposition1 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("good", "bonne", "goed"),
                    Position = 1
                };

                var QuestionProposition2 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("medium", "moyenne", "gemiddelde"),
                    Position = 2
                };

                var QuestionProposition3 = new QuestionPropositionTO
                {
                    Question = questionAdded1,
                    Libelle  = new MultiLanguageString("bad", "mauvaise", "slecht"),
                    Position = 3
                };

                var QuestionProposition4 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("yes", "oui", "ja"),
                    Position = 1
                };

                var QuestionProposition5 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("too fast", "trop rapide", "te snel"),
                    Position = 2
                };

                var QuestionProposition6 = new QuestionPropositionTO
                {
                    Question = questionAdded2,
                    Libelle  = new MultiLanguageString("too slow", "trop lent", "te langzaam"),
                    Position = 3
                };

                var questionPropositionAdded1 = questionPropositionRepository.Add(QuestionProposition1);
                var questionPropositionAdded2 = questionPropositionRepository.Add(QuestionProposition2);
                var questionPropositionAdded3 = questionPropositionRepository.Add(QuestionProposition3);
                var questionPropositionAdded4 = questionPropositionRepository.Add(QuestionProposition4);
                var questionPropositionAdded5 = questionPropositionRepository.Add(QuestionProposition5);
                var questionPropositionAdded6 = questionPropositionRepository.Add(QuestionProposition6);
                memoryContext.SaveChanges();
                #endregion

                // Act
                var forms                = formRepository.GetAll();
                var questions            = questionRepository.GetAll();
                var questionPropositions = questionPropositionRepository.GetAll();
                var count                = forms.Count();

                // Assert
                Assert.AreEqual(3, count);

                foreach (var form in forms)
                {
                    Console.WriteLine(form.Id);
                    Console.WriteLine(form.Name.French);
                    Console.WriteLine();

                    foreach (var question in questions.Where(q => q.Form.Id == form.Id).ToList())
                    {
                        Console.WriteLine($"\tId : {question.Id} - Position : {question.Position} - Type : {question.Type} - {question.Libelle.French}");
                        Console.WriteLine();

                        foreach (var questionProposition in questionPropositions.Where(qp => qp.Question.Id == question.Id))
                        {
                            Console.WriteLine($"\tId : {questionProposition.Id} - Position : {questionProposition.Position} - {questionProposition.Libelle.French}");
                            Console.WriteLine();
                        }
                    }
                }
            }
        }
Esempio n. 23
0
 public IEnumerable <QuestionDTO> GetAll(Func <QuestionDTO, bool> predicate = null)
 {
     return(_questionRepository.GetAll().Select(QuestionDTO.ToDTO));
 }