public void QuestionBcTests_UpdateQuestion() { var random = TestUtils.RandomString(10); var search = new BaseSearchModel { Limit = 10, Offset = 0, Filter = "Random" }; var result = questionBc.GetSearchQuery(search); if (!result.Any()) { Assert.Inconclusive(); } else { bool updated = false; foreach (var question in result) { if (question.Choices.Any()) { var dbQuestion = result.FirstOrDefault(); var original = dbQuestion.Question; dbQuestion.Id = dbQuestion.Id; dbQuestion.Question = $"Updated description {random}"; dbQuestion.Choices = new QuestionChoiceResponseModel[] { new QuestionChoiceResponseModel { Name = $"choice_{random}", Votes = 1 } }; var updatedQuestion = questionBc.UpdateQuestion(dbQuestion); Assert.AreNotEqual(original, updatedQuestion.Question); updated = true; break; } } if (!updated) { Assert.Inconclusive(); } } }
public async Task <IHttpActionResult> UpdateQuestion( long id, QuestionResponseModel model, CancellationToken cancellationToken = default(CancellationToken)) { return(await ExecuteAsync <IHttpActionResult>(() => { if (!ModelState.IsValid) { throw new BlissException(CommonExceptionResources.AllFieldsMandatory); } return Ok(questionBc.UpdateQuestion(model)); }, cancellationToken)); }