public void WhenIsSkippedFlagAsSkipped() { // Arrange var mockSpeachService = new Mock <ISpeachService>(); var spellings = new ObservableCollection <SpellingViewModel>(); var s = new Spelling() { Word = "Dog", ContextSentence = "The dog and bone" }; var svm = new SpellingViewModel(s); spellings.Add(svm); var sut = new SpellTestService(spellings, mockSpeachService.Object); sut.NextQuestion(); // Act sut.SkipQuestion(); // Assert Assert.Equal(svm.CorrectCount, 0); Assert.Equal(svm.ErrorCount, 0); Assert.Equal(svm.Skipped, true); }
public void Next_Should_Return_Null_When_All_Answered() { // Arrange var mockSpeachService = new Mock <ISpeachService>(); var spellings = new ObservableCollection <SpellingViewModel>(); var s = new Spelling() { Word = "Dog", ContextSentence = "The dog and bone" }; var svm = new SpellingViewModel(s); spellings.Add(svm); var sut = new SpellTestService(spellings, mockSpeachService.Object); var q = sut.NextQuestion(); // Act q = sut.AnswerQuestion("Dog"); // Assert Assert.Null(q); q = sut.NextQuestion(); Assert.Null(q); }
public void WhenIsAnsweredIncorrectlyErrorCountIncreases() { // Arrange var mockSpeachService = new Mock <ISpeachService>(); var spellings = new ObservableCollection <SpellingViewModel>(); var s = new Spelling() { Word = "Dog", ContextSentence = "The dog and bone" }; var svm = new SpellingViewModel(s); spellings.Add(svm); var sut = new SpellTestService(spellings, mockSpeachService.Object); sut.NextQuestion(); // Act sut.AnswerQuestion("Dogg"); // Assert Assert.Equal(svm.CorrectCount, 0); Assert.Equal(svm.ErrorCount, 1); Assert.Equal(svm.Skipped, false); }
public ActionResult Index(SpellingViewModel model) { // Update words file string path = Server.MapPath(@"~/App_Data/words.txt"); StringBuilder fileContent = new StringBuilder(); fileContent.AppendLine(model.Word1) .AppendLine(model.Word2) .AppendLine(model.Word3) .AppendLine(model.Word4) .AppendLine(model.Word5) .AppendLine(model.Word6) .AppendLine(model.Word7) .AppendLine(model.Word8) .AppendLine(model.Word9) .AppendLine(model.Word10); // Trim the last newline and carriage return at the end of the file fileContent.Length -= 2; System.IO.File.WriteAllText(path, fileContent.ToString()); return(RedirectToAction("Index", "Setup")); }
public SpellingViewModel NextQuestion() { var unanswered = Questions.Where(q => q.CorrectCount < 1 && !q.Skipped); if (unanswered.Count() == 0) { return(null); } int i = _rnd.Next(0, unanswered.Count()); _current = unanswered.ElementAt(i); return(_current); }
public ActionResult Index(SpellingViewModel model) { var list = new List <string> { }; list.Add(model.Answer1); list.Add(model.Answer2); list.Add(model.Answer3); list.Add(model.Answer4); list.Add(model.Answer5); list.Add(model.Answer6); list.Add(model.Answer7); list.Add(model.Answer8); list.Add(model.Answer9); list.Add(model.Answer10); TempData["answerList"] = list; return(RedirectToAction("Index", "Result")); }
// GET: Practice public ActionResult Index() { // Get the words from a text file var listService = new ListService(); var words = listService.GetWords(); var model = new SpellingViewModel(); model.Word1 = ""; model.Word2 = ""; model.Word3 = ""; model.Word4 = ""; model.Word5 = ""; model.Word6 = ""; model.Word7 = ""; model.Word8 = ""; model.Word9 = ""; model.Word10 = ""; if (words[0] != null) { model.Word1 = words[0]; } if (words[1] != null) { model.Word2 = words[1]; } if (words[2] != null) { model.Word3 = words[2]; } if (words[3] != null) { model.Word4 = words[3]; } if (words[4] != null) { model.Word5 = words[4]; } if (words[5] != null) { model.Word6 = words[5]; } if (words[6] != null) { model.Word7 = words[6]; } if (words[7] != null) { model.Word8 = words[7]; } if (words[8] != null) { model.Word9 = words[8]; } if (words[9] != null) { model.Word10 = words[9]; } return(View(model)); }