public void Returns_text_when_has_multiple_default_separator() { var choices = new List <Choice> { new Choice() { Text = "1" }, new Choice() { Text = "2" }, new Choice() { Text = "3" } }; var poll = new Poll() { Choices = choices }; var converter = new ChoiceConverter(poll); var result = converter.GetTextFromChoices(); Assert.Equal($"1{NL}2{NL}3", result); }
public void Returns_empty_list_on_empty_text() { var converter = new ChoiceConverter(new Poll()); var result = converter.GetChoices(string.Empty); Assert.Empty(result); }
public void Returns_zero_element_when_no_separator() { var text = $"*Un *deux *trois{NL}*Quatre *cinq six*{NL}*Sept *Huit *Neuf{NL}*Dix *onze *douze"; var converter = new ChoiceConverter(new Poll(), separator: "_"); var result = converter.GetChoices(text); Assert.Single(result); }
public void Returns_one_element_when_no_separators() { var text = $"Un deux trois*Quatre cinq six*Sept Huit Neuf*Dix onze douze"; var converter = new ChoiceConverter(new Poll()); var result = converter.GetChoices(text); Assert.Single(result); }
public void Returns_multiple_elements_when_multiple_separators() { var text = $"*Un *deux *trois{NL}*Quatre *cinq six*{NL}*Sept *Huit *Neuf{NL}*Dix *onze *douze"; var converter = new ChoiceConverter(new Poll()); var result = converter.GetChoices(text); Assert.Equal(4, result.Count()); }
public void Returns_elements_when_has_multiple_not_default_separator() { var text = $"_Un _deux _trois{NL}_Quatre _cinq six_{NL}_Sept _Huit _Neuf{NL}_Dix _onze _douze"; var converter = new ChoiceConverter(new Poll(), separator: "_"); var result = converter.GetChoices(text); Assert.Equal(12, result.Count()); }
public async Task <IActionResult> EditPoll(long id) { var poll = await(from p in PollContext.Polls.Include(e => e.Choices) where p.Id == id select p).FirstOrDefaultAsync(); var converter = new ChoiceConverter(poll); if (poll == null) { throw new EntityNotFoundException(typeof(Poll), poll.Id); } else { return(View(new RawPollViewModel() { Choices = converter.GetTextFromChoices(), Question = poll.Question, PollId = poll.Id, StartDate = poll.StartDateLocal, EndDate = poll.EndDateLocal, })); } }