public void GivenTheFirstQuestionIsWithTheFollowingAnswers(string questionKey, string questionText, Table answers) { SurveySays.Domain.Api.Survey survey = ScenarioContext.Current["Survey"] as SurveySays.Domain.Api.Survey; SingleChoiceQuestion question = new SingleChoiceQuestion(questionText); foreach (var item in answers.Rows) { Choice choice = new Choice(); choice.DisplayText = item[0]; choice.Value = item["Answer"]; choice.Id = Guid.NewGuid(); question.AddChoice(choice); } survey.AddQuestion(question); ScenarioContext.Current["question-" + questionKey] = question; }
private void PopulateAnswers(ChoiceQuestion question, string answers) { foreach (var answer in answers.Split(',')) { string cleanAnswer = answer.Trim(); Choice choice = new Choice() { DisplayText = cleanAnswer, Value = cleanAnswer, Id = Guid.NewGuid() }; question.AddChoice(choice); } }
public bool IsChoiceSelected(Choice choice) { return this.Answer != null && this.Answer.Id.Equals(choice.Id); }