public void ShouldMatchCharKeyWithWordLetter()
        {
            //Arrange
            var viewModel = new GameOneViewModel(new HomeWindowViewModel());
            viewModel.Words = GameOneDataSource.InitializeDummyData();

            //Act
        }
        public void ShouldSetTheStartTimeOnProcessStart()
        {
            //Arrange
            var viewModel = new GameOneViewModel(new HomeWindowViewModel());

            viewModel.ProcessStart.Execute(null);

            Assert.IsNotNull(viewModel.ProcessStartTime);
        }
 public object CreateViewModel(ViewModelBase parentViewModel)
 {
     var gameOneViewModel = new GameOneViewModel(parentViewModel as HomeWindowViewModel);
     gameOneViewModel.ServiceLocator.RegisterService<IGameOneDataSource>(new GameOneDataSource());
     gameOneViewModel.CurrentWordIndex = 0;
     gameOneViewModel.RefreshGameData();
     gameOneViewModel.LoadData();
     gameOneViewModel.SetFirstWord(gameOneViewModel.Words.First());
     return gameOneViewModel;
 }
        public void Should_Pass_The_letter_to_the_current_word_viewmodel()
        {
            var viewModel = new GameOneViewModel(new HomeWindowViewModel());
            viewModel.Words = GameOneDataSource.InitializeDummyData();

            viewModel.CurrentWord = viewModel.Words[0];
            var firstLetterOfFirstWord = viewModel.Words[0].Letters[0].Letter;
            viewModel.KeyPressReceivedCommand.Execute(firstLetterOfFirstWord);

            Assert.AreEqual(viewModel.Words[0].CurrentLetter, firstLetterOfFirstWord.ToString());
        }
        public void ShouldStoreTheCurrentTypedLetter()
        {
            var viewModel = new GameOneViewModel(new HomeWindowViewModel());
            viewModel.Words = GameOneDataSource.InitializeDummyData();

            viewModel.CurrentWord = viewModel.Words[0];
            viewModel.KeyPressReceivedCommand.Execute("b");

            //Assert
            Assert.IsTrue(viewModel.TypedLetter == "b");
        }
        public static WordViewModel GetRandomWord(int wordLength)
        {
            var gameOneViewModel = new GameOneViewModel(new HomeWindowViewModel());
            var wordViewModel = new WordViewModel(gameOneViewModel);
            wordViewModel.WordHeight = 17;

            string alphabets = "abdcdefghijklmnopqrstuvwxyz";
            var random = new Random();

            for (int i = 0; i < wordLength; i++)
            {
                char letter = alphabets[random.Next(alphabets.Length)];
                wordViewModel.Letters.Add(new TypeFaceViewModel(letter, 16));
            }
            return wordViewModel;
        }
        public IList<WordViewModel> ImportGameData(GameOneViewModel gameViewModel)
        {
            var words = new List<WordViewModel>();
            var fileName = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(typeof (WordViewModel)).Location), @"DesignData\GameOneData.txt");
            var fileData = File.ReadAllText(fileName);
            var v = (char) 32;
            var result = fileData.Split(v);
            var durationStart = DateTime.Now;
            var firstWord = CreateWordViewModelFromWordString(result[0]);
            firstWord.StartAnimation = true;
            words.Add(firstWord);
            words.Add(GetSpaceLetterWord());

            for (int i = 1; i < result.Length; i++)
            {
                words.Add(CreateWordViewModelFromWordString(result[i]));
                words.Add(GetSpaceLetterWord());
            }
            var duration = DateTime.Now.Subtract(durationStart);

            return words;
        }
 public WordViewModel(GameOneViewModel gameViewModel)
 {
     _gameViewModel = gameViewModel;
     _letters = new ObservableCollection<TypeFaceViewModel>();
 }
        private WordViewModel CreateWordViewModelFromWordString(string word)
        {
            var gameOneViewModel = new GameOneViewModel(new HomeWindowViewModel());
            var wordViewModel = new WordViewModel(gameOneViewModel);
            wordViewModel.WordHeight = 17;

            foreach (var character in word)
            {
                char letter = character;
                wordViewModel.Letters.Add(new TypeFaceViewModel(letter, 16));
            }
            return wordViewModel;
        }
 public IList<WordViewModel> GetGameData(GameOneViewModel gameViewModel)
 {
     return ImportGameData(gameViewModel);
 }
        private void LoadGameOne()
        {
            if (Workspace is GameOneViewModel) return;
            _gameOneViewModel = new GameOneViewModel(this);
            _gameOneViewModel.ServiceLocator.RegisterService(GetService<IGameOneDataSource>());

            _gameOneViewModel.GameData = GetService<IGameOneDataSource>().GetGameData();
            _gameOneViewModel.GameData.each(x => _gameOneViewModel.AddWord(x));
            _gameOneViewModel.SetFirstWord(_gameOneViewModel.Words.First());
            _gameOneViewModel.ProcessStart.Execute(null);
            Workspace = _gameOneViewModel;
        }