public void Should_show_game_finish_flyout_when_last_word_is_inserted_onto_the_board() { var puzzleBoardVm = new TestPuzzleBoardViewModel(new FakePuzzlesService(), new TestSchedulers(), new FakeUserSevice()); Messenger.Default.Register<GameCompleteMessage>(this, m => Assert.AreEqual(11, m.ScorePercentage)); GetDesignPuzzleBoardViewModelWithAllWordsInsertedButSomeAnswersWrong(puzzleBoardVm); Assert.AreEqual("You scored 11%", puzzleBoardVm.GameScoreDisplay); Assert.IsTrue(puzzleBoardVm.ShowGameOverPopup); }
public void Should_execute_GameFinishedEvent_with_resulte_less_than_100_percent_result_when_the_odd_word_inserted_onto_the_board_is_wrong() { var puzzleBoardVm = new TestPuzzleBoardViewModel(new FakePuzzlesService(), new TestSchedulers(), new FakeUserSevice()); Messenger.Default.Register<GameCompleteMessage>(this, m => Assert.IsTrue( m.ScorePercentage < 100)); GetDesignPuzzleBoardViewModelWithAllWordsInsertedButSomeAnswersWrong(puzzleBoardVm); }
public static TestPuzzleBoardViewModel PuzzleBoardWith3Words() { var fakePuzzleService = new FakePuzzlesService(); fakePuzzleService.AddWords(new Dictionary<string, string> { {"Bamidele", "Adetoro's first name"}, {"station", "place where i fit get train"}, {"india", "Origin of my favourite curry"}, }); var puzzleBoardViewModel = new TestPuzzleBoardViewModel(fakePuzzleService, new TestSchedulers(), new FakeUserSevice()); var puzzleVm = new PuzzleViewModel() { PuzzleId = 1 }; puzzleBoardViewModel.LoadState(puzzleVm, new Dictionary<string, object>()); return puzzleBoardViewModel; }
private static TestPuzzleBoardViewModel GetDesignPuzzleBoardViewModelWithAllWordsInsertedButSomeAnswersWrong(TestPuzzleBoardViewModel puzzleBoardVm) { var puzzleVm = new PuzzleViewModel() { PuzzleId = 1 }; puzzleBoardVm.LoadState(puzzleVm, new Dictionary<string, object>()); puzzleBoardVm.StartPauseButtonCaption = "Start"; puzzleBoardVm.GameIsRunning = false; puzzleBoardVm.StartPauseCommand.Execute(null); //Act puzzleBoardVm.SelectedWordAcross = puzzleBoardVm.Words.First(); for (int index = 0; index < puzzleBoardVm.Words.Count; index++) { var word = puzzleBoardVm.Words[index]; if (word.Direction == Direction.Down) { puzzleBoardVm.SelectedWordDown = word; } else { puzzleBoardVm.SelectedWordAcross = word; } foreach (var cell in word.Cells) { var newValue = cell.Value; if (index % 2 == 0) newValue = "x"; Messenger.Default.Send(new KeyReceivedMessage() {KeyChar = newValue}); } puzzleBoardVm.AddEnteredWordOnToBoardCommand.Execute(null); } return puzzleBoardVm; }