public void WriteQuestionToDatabase_IsValid_False() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); Mock <Category> category = new Mock <Category>("Medisch"); //To much characters Mock <Question> question = new Mock <Question>(1, MockMaxCharacters, "baa", Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); Mock <Question> question2 = new Mock <Question>(1, "sup", MockMaxCharacters, Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); //Empty properties Mock <Question> question3 = new Mock <Question>(1, "", "baa", Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); Mock <Question> question4 = new Mock <Question>(1, "sup", "", Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); Assert.ThrowsException <ArgumentException>(() => questionLogic.WriteQuestionToDatabase(question.Object)); Assert.ThrowsException <ArgumentException>(() => questionLogic.WriteQuestionToDatabase(question2.Object)); Assert.ThrowsException <ArgumentException>(() => questionLogic.WriteQuestionToDatabase(question3.Object)); Assert.ThrowsException <ArgumentException>(() => questionLogic.WriteQuestionToDatabase(question4.Object)); }
private void btnSaveQuestion_Click(object sender, EventArgs e) { int categorySelectedIndex = cmbCategory.SelectedIndex; string subjectNew; string contentNew; string urgency; if (cbUrgent.Checked == true) { urgency = "Urgent"; } else { urgency = "Not Urgent"; } subjectNew = (tbSubjectNew.Text == "") ? tbSubjectOld.Text : tbSubjectNew.Text; contentNew = (tbContentNew.Text == "") ? tbContentOld.Text : tbContentNew.Text; if (categorySelectedIndex == -1) { // QuestionContextSQL.FormCareEditQuestion(questionID, subjectNew, contentNew, urgency); } else { Category category = categories[categorySelectedIndex]; QuestionLogic.EditQuestion(_question.QuestionId, subjectNew, contentNew, category, urgency); MessageBox.Show("Hulpvraag bewerkt."); ((FormMain)this.Parent.Parent).ReplaceForm(new FormCareQuestionOverview()); } }
private void btnRequest_Click(object sender, EventArgs e) { if (CategoryComboboxIsNotEmpty() == true && SubmittedValuesNotEmpty() == true) { int categorySelectedIndex = cboxCategory.SelectedIndex; try { Category category = categories[categorySelectedIndex]; string urgency = cbUrgent.Checked ? "Urgent" : "NotUrgent"; Question newQuestion = new Question(tbSubject.Text, tbDescription.Text, Question.QuestionStatus.Open, DateTime.Now, urgency, category, FormLogin.currentUser.UserId); QuestionLogic.WriteQuestionToDatabase(newQuestion); MessageBox.Show("De hulpvraag is succesvol aangemaakt"); ((FormMain)this.Parent.Parent).ReplaceForm(new FormCareQuestionOverview()); } catch (ArgumentOutOfRangeException) { MessageBox.Show("Categorie fout."); } } else { MessageBox.Show("Something went wrong."); } }
public VolunteerController(QuestionLogic questionLogic, UserLogic userLogic, ReactionLogic reactionLogic, ChatLogic chatLogic, AppointmentLogic appointmentLogic) { _questionLogic = questionLogic; _userLogic = userLogic; _reactionLogic = reactionLogic; _chatLogic = chatLogic; _appointmentLogic = appointmentLogic; }
// Instantiating the questionLogic public QuizController() { questionLogic = new QuestionLogic(); room_LevelsLogic = new Room_LevelsLogic(); player_StatusLogic = new Player_StatusLogic(); UserLogic = new UserLogic(); RoomLogic = new RoomLogic(); }
public AdminController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, LogLogic logLogic) { _questionLogic = questionLogic; _categoryLogic = categoryLogic; _reactionLogic = reactionLogic; _userLogic = userLogic; _chatLogic = chatLogic; _logLogic = logLogic; }
static void Main() { Voter TestVoter = new Voter(12345); List <Question> questions = QuestionLogic.CreateTheFeedbackQuestions(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new UI_Feedback(questions)); }
public CareRecipientController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, AppointmentLogic appointmentLogic) { _questionLogic = questionLogic; _categoryLogic = categoryLogic; _reactionLogic = reactionLogic; _userLogic = userLogic; _chatLogic = chatLogic; _appointmentLogic = appointmentLogic; }
public ReviewController(QuestionLogic questionLogic, CategoryLogic categoryLogic, ReactionLogic reactionLogic, UserLogic userLogic, ChatLogic chatLogic, ReviewLogic reviewLogic) { _questionLogic = questionLogic; _categoryLogic = categoryLogic; _reactionLogic = reactionLogic; _userLogic = userLogic; _chatLogic = chatLogic; _reviewLogic = reviewLogic; }
public FormCareQuestionOverview() { InitializeComponent(); List <ListViewItem> items = QuestionLogic.LoadQuestionsToList(QuestionLogic.GetAllOpenQuestionCareRecipientID(FormLogin.currentUser.UserId)); foreach (ListViewItem item in items) { lvOpenQuestions.Items.Add(item); } }
public void GetAllQuestions_IsValid() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); questionLogic.GetAllQuestions(); mockContext.Verify(x => x.GetAllQuestions(), Times.Exactly(1)); }
public IHttpActionResult AddQuestion([FromBody] QuestionDTO question) { try { return(Ok(QuestionLogic.AddQuestion(question))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void ChangeQuestionStatus_IsValid() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); Category category = new Category("Medisch"); Question question = new Question(1, "foo", "baa", Question.QuestionStatus.Closed, DateTime.Today, true, category, 12); QuestionLogic logic = new QuestionLogic(mockContext.Object); logic.ChangeStatus(question.QuestionId, Question.QuestionStatus.Closed.ToString()); Assert.AreNotEqual(question.Status.ToString(), "Open"); }
public void WriteQuestionToDatabase_IsValid_True() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); Mock <Category> category = new Mock <Category>("Medisch"); Mock <Question> question = new Mock <Question>(1, "foo", "baa", Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); mockContext.Setup(x => x.AddQuestion(question.Object)); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); questionLogic.WriteQuestionToDatabase(question.Object); mockContext.Verify(x => x.AddQuestion(question.Object), Times.Exactly(1)); }
public void GetAllOpenQuestion_IsValid() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); List <Question> stub = new List <Question>(); mockContext.Setup(x => x.GetAllOpenQuestionsVolunteer()) .Returns(stub); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); List <Question> result = questionLogic.GetAllOpenQuestions(); Assert.IsInstanceOfType(result, typeof(List <Question>)); }
// Edit Question private void btnEditQuestiFormCareEditQuestionon_Click(object sender, EventArgs e) { if (lvOpenQuestions.SelectedItems.Count == 1) { int selectedRow = lvOpenQuestions.SelectedItems[0].Index; int selectedId = Convert.ToInt32(lvOpenQuestions.Items[selectedRow].SubItems[5].Text); ((FormMain)this.Parent.Parent).ReplaceForm(new FormCareEditQuestion(QuestionLogic.GetSingleQuestion(selectedId))); } else { MessageBox.Show("Error"); } }
public void GetSingleQuestion_IsValid() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); Mock <Category> category = new Mock <Category>("Medisch"); Mock <Question> question = new Mock <Question>(1, "foo", "baa", Question.QuestionStatus.Open, DateTime.Today, true, category.Object, 12); mockContext.Setup(x => x.GetSingleQuestion(question.Object.QuestionId)) .Returns(question.Object); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); Question result = questionLogic.GetSingleQuestion(question.Object.QuestionId); Assert.IsInstanceOfType(result, typeof(Question)); }
public void GetQuestionDetailsAsync_Returns_List_Of_QuestionDetail() { var mockRepo = new Mock <IQuestionRepository>(); mockRepo.Setup(mr => mr.GetQuestionDetailsAsync()) .ReturnsAsync(repoDetails); var sut = new QuestionLogic(mockRepo.Object); var questionDetails = sut.GetQuestionDetailsAsync(); Assert.IsType <List <QuestionDetail> >(questionDetails.Result); Assert.NotEmpty(questionDetails.Result); }
public void GetQuestionDetailsAsync_Returns_Only_QuestionDetails_With_Multiple_Answers() { var mockRepo = new Mock <IQuestionRepository>(); mockRepo.Setup(mr => mr.GetQuestionDetailsAsync()) .ReturnsAsync(repoDetails); var sut = new QuestionLogic(mockRepo.Object); var questionDetails = sut.GetQuestionDetailsAsync(); Assert.IsType <List <QuestionDetail> >(questionDetails.Result); Assert.All(questionDetails.Result, qd => Assert.True(qd.AnswerCount > 1)); }
public void GetAllClosedQuestionsCareRecipientID_IsValid() { Mock <IQuestionContext> mockContext = new Mock <IQuestionContext>(); List <Question> stub = new List <Question>(); User user = new Mock <User>(1, "Jesse", "Oosterwijk", "Kleidonk 1", "Beuningen", "6641LM", "*****@*****.**", DateTime.Today, User.Gender.Man, true, User.AccountType.CareRecipient, "1111").Object; mockContext.Setup(x => x.GetAllClosedQuestionsCareRecipient(user.UserId)) .Returns(stub); QuestionLogic questionLogic = new QuestionLogic(mockContext.Object); List <Question> result = questionLogic.GetAllClosedQuestionsCareRecipientId(user.UserId); Assert.IsInstanceOfType(result, typeof(List <Question>)); }
//React to Question private void btnReactToQuestion_Click(object sender, EventArgs e) { if (lvOpenQuestions.SelectedItems.Count == 0) { MessageBox.Show("Selecteer eerst een vraag uit de lijst."); } else { int selectedRow = lvOpenQuestions.SelectedItems[0].Index; int selectedId = Convert.ToInt32(lvOpenQuestions.Items[selectedRow].SubItems[5].Text); Form questionReaction = new FormVolQuestionReaction(QuestionLogic.GetSingleQuestion(selectedId)); questionReaction.Show(); } }
public WebResult GetQuestions(int teacherId) { WebResult wb = new WebResult(); try { wb.value = QuestionLogic.GetQuestionsForTeacher(teacherId); wb.message = "success"; wb.status = true; return(wb); } catch (Exception ex) { wb.status = false; wb.message = ex.Message; return(wb); } }
public void GetQuestionDetails_Returns_Empty_List_When_No_Accepted_Answers() { var mockRepo = new Mock <IQuestionRepository>(); mockRepo.Setup(mr => mr.GetQuestionDetailsAsync()) .ReturnsAsync(new List <QuestionDetail> { new QuestionDetail { AcceptedAnswerId = null } }); var sut = new QuestionLogic(mockRepo.Object); var questionDetails = sut.GetQuestionDetailsAsync(); Assert.IsType <List <QuestionDetail> >(questionDetails.Result); Assert.Empty(questionDetails.Result); }
public WebResult GetQuestionsForSubCat(int subCategoryId, int level) { WebResult wb = new WebResult(); try { wb.value = QuestionLogic.GetQuestions(subCategoryId, level); wb.message = "success"; wb.status = true; return(wb); } catch (Exception ex) { wb.status = false; wb.message = ex.Message; return(wb); } }
public void LoadQuestionsToList() { DataTable dt = new DataTable(); dt = QuestionLogic.GetAllOpenQuestions(); //Adding each row into listview with foreach + for loop foreach (DataRow row in dt.Rows) { //Standard adding item, only add the primary key as main item ListViewItem item = new ListViewItem(row[0].ToString()); for (int i = 1; i < dt.Columns.Count; i++) { //each item that follow the primary key will be added as sub item item.SubItems.Add(row[i].ToString()); } lvOpenQuestions.Items.Add(item); } }
public WebResult AddQuestion([FromBody] JObject obj) { QuestionDTO question = obj["ques"].ToObject <QuestionDTO>(); List <AnswerDTO> answers = obj["ans"].ToObject <List <AnswerDTO> >(); WebResult wr = new WebResult(); try { wr.value = QuestionLogic.AddQuestion(question, answers); wr.message = "success"; wr.status = true; return(wr); } catch (Exception ex) { wr.status = false; wr.message = ex.Message; return(wr); } }
public AddQuestInTest(QuestionLogic logic) { InitializeComponent(); this.logic = logic; LoadData(); }
public QuestionManagementController() { _el = new QuestionLogic(); _al = new AuthorityManageLogic(); }
public QuestAdd(QuestionLogic questionLogic) { InitializeComponent(); this.questionLogic = questionLogic; }
public QuestionViewModelsController() { _Logic = new QuestionLogic(); }