public async void CanAddQuestion() { var mockTopic = new DataEntity.Topic(); _topicRepositoryMock.Setup(tr => tr.GetTopicAsync(It.IsAny <string>())) .ReturnsAsync(mockTopic); var result = await _questionController.Add(new ResponseData.QuestionIgnoreId { TopicId = "9765a3fa50f5fea28212ba" }); var actualResult = Assert.IsType <StatusCodeResult>(result); Assert.Equal((int)HttpStatusCode.Created, actualResult.StatusCode); }
private void QuestionAdd_Click(object sender, RoutedEventArgs e) { if (CheckFillingQuestionFields()) { if (CheckAnswersCount()) { if (CheckExistRightAnswer()) { questionController.Add(new Question() { SurveyId = _survey.Id, Text = !string.IsNullOrEmpty(QuestionText.Text) ? QuestionText.Text : string.Empty, Foto = QuestionPicture.Source != null ? ConvertPicture.BitmapImageToByteArray((BitmapImage)QuestionPicture.Source) : null }, _answers); _answers.Clear(); UpdateQuestionTable(); } else { MessageBox.Show(LangPages.MBox.MissingCorrectAnswer); } } else { MessageBox.Show(LangPages.MBox.NeedToAddQuestionAnswers); } } else { MessageBox.Show(LangPages.MBox.NotAllFieldsInTheQuestionAreFilled); } }
private void toolStripMenuItem_AddNewQuestion_Click(object sender, EventArgs e) { MaterialMessageInput.MessageBoxResultInput result = MaterialMessageInput.MessageBoxResultInput.None; long SurveyID = Convert.ToInt64(txt_EditSurveyDetailsName.Tag); if (SurveyID != -1) { result = MaterialMessageInput.Show("Noua intrebare care sa fie adaugata in chestionar:", "Easy Survey - Add New Question", MaterialMessageInput.MessageBoxButtonsInput.OKCancel, addQuestion: true); } if (result == MaterialMessageInput.MessageBoxResultInput.OK) { using (QuestionController questionController = new QuestionController()) { string QuestionName = MaterialMessageInput.Answer; // long SurveyID = Convert.ToInt64(txt_EditSurveyDetailsName.Tag); Question newQuestion = new Question { Question1 = QuestionName }; questionController.Add(ref newQuestion, SurveyID); ListViewItem newQuestionItem = new ListViewItem() { Tag = newQuestion.QuestionID.ToString(), Text = newQuestion.Question1 }; listView_EditSurveyQuestions.Items.Add(newQuestionItem); int QuestionIndex = listView_EditSurveyQuestions.Items.Count - 1; listView_EditSurveyQuestions.Items[QuestionIndex].Selected = true; listView_EditSurveyQuestions.Items[QuestionIndex].Focused = true; listView_EditSurveyQuestions.Items[QuestionIndex].EnsureVisible(); } } }