public void When_StartPuzzleMessage_is_received_Should_set_the_GameId_property_on_the_PuzzleBoardViewModel()
        {
            var fakePuzzleService = new FakePuzzlesService();

            var puzzleBoardVm = new PuzzleBoardViewModel(fakePuzzleService, new TestSchedulers(), new FakeUserSevice());
            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 puzzleViewModel = new PuzzleViewModel() { PuzzleId = 1 };
            puzzleBoardVm.LoadState(puzzleViewModel, new Dictionary<string, object>());
            Assert.AreEqual(puzzleViewModel.PuzzleId, puzzleBoardVm.PuzzleViewModel.PuzzleId);
        }
예제 #2
0
 public static PuzzleViewModel FakePuzzleBuilder(string title)
 {
     var puzzleVm = new PuzzleViewModel
                        {Title = title,
                            Words =
                            new List<string>
                                    {
                                        "First",
                                        "Second",
                                        "Third",
                                        "Forth",
                                        "Fifth",
                                        "Sixth"
                                    }
                        };
     return puzzleVm;
 }
        public async Task When_StartPauseCommand_is_executed_should_get_from_PuzzleService_words_for_the_provided_puzzleId()
        {
            var fakePuzzleService = new FakePuzzlesService();

            var puzzleBoardVm = new PuzzleBoardViewModel(fakePuzzleService, new TestSchedulers(), new FakeUserSevice());
            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 puzzleViewModel = new PuzzleViewModel() {PuzzleId = 1};
            puzzleBoardVm.LoadState(puzzleViewModel,new Dictionary<string, object>());
            puzzleBoardVm.StartPauseCommand.Execute(null);
            Assert.AreEqual(3, puzzleBoardVm.Words.Count);
        }
        public DesignPuzzleBoardViewModel()
            : base(new FakePuzzlesService(), new TestSchedulers(), new FakeUserSevice())
        {
            Debug.WriteLine("Username {0}", CurrentUser);
            Debug.WriteLine("StartPauseButtonCaption {0}", StartPauseButtonCaption);
            CurrentUser = "******";

            PuzzleViewModel = new PuzzleViewModel() {Group = "Science", Title = "Level One"};
            Words = _puzzlesService.GetOrdereredWordsForPuzzle(0,CurrentUser);

            SelectedWord = (from word in Words
                               where word.Word.Equals("india",StringComparison.OrdinalIgnoreCase)
                               select word).FirstOrDefault();

            GameIsRunning = true;

            StartPauseButtonCaption = "Pause";

            GameCountDown = "00:00:00";

            AcrossAndDownVisible = true;

            AddWordsToBoard();
        }
예제 #5
0
 private void StartPuzzle(PuzzleViewModel puzzleViewModel)
 {
     navigation.Navigate<PuzzleBoard>(puzzleViewModel);
 }
        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;
        }
        public void Board_should_be_disabled_if_game_is_not_running()
        {
            var fakePuzzleService = new FakePuzzlesService();
            var puzzleBoardVm = new PuzzleBoardViewModel(fakePuzzleService, new TestSchedulers(), new FakeUserSevice());
            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 puzzleViewModel = new PuzzleViewModel() { PuzzleId = 1 };
            puzzleBoardVm.LoadState(puzzleViewModel, new Dictionary<string, object>());

            puzzleBoardVm.StartPauseCommand.Execute(null);
            Assert.IsTrue(puzzleBoardVm.GameIsRunning);
        }
        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;
        }