コード例 #1
0
        public WordTutorApplication Reduce(IReduxMessage message, WordTutorApplication currentState)
        {
            if (currentState is null)
            {
                throw new ArgumentNullException(nameof(currentState));
            }

            if (!(currentState.CurrentScreen is VocabularyBrowserScreen))
            {
                return(currentState);
            }

            return((message ?? throw new ArgumentNullException(nameof(message)))
                   switch
            {
                ClearSelectedWordMessage _ => currentState.UpdateScreen(
                    (VocabularyBrowserScreen s) => s.ClearSelection()),

                SelectWordMessage m => currentState.UpdateScreen(
                    (VocabularyBrowserScreen s) => s.WithSelection(m.Word)),

                OpenScreenForNewWordMessage _ => currentState.OpenScreen(
                    ModifyVocabularyWordScreen.ForNewWord()),

                OpenScreenForModifyingWordMessage m => currentState.OpenScreen(
                    ModifyVocabularyWordScreen.ForExistingWord(m.Word)),

                _ => currentState,
            });
コード例 #2
0
        public void Create_WhenGivenScreen_ReturnsExpectedViewModel()
        {
            var screen    = ModifyVocabularyWordScreen.ForNewWord();
            var viewModel = _factory.Create(screen);

            viewModel.Should().NotBeNull();
            viewModel.Should().BeOfType <ModifyVocabularyWordViewModel>();
        }
コード例 #3
0
            public void WhenScreenConfigured_ReturnsExpectedWord()
            {
                var screen =
                    ModifyVocabularyWordScreen.ForNewWord()
                    .WithSpelling(_word.Spelling)
                    .WithPronunciation(_word.Pronunciation)
                    .WithPhrase(_word.Phrase);

                screen.AsWord().Should().Be(_word);
            }
コード例 #4
0
        public ModifyVocabularyWordScreenReducerTests()
        {
            var screen =
                ModifyVocabularyWordScreen.ForNewWord()
                .WithSpelling("Phoo")
                .WithPronunciation("Foo")
                .WithPhrase("Phrase");

            _initialState = new WordTutorApplication(screen);
        }
        public ModifyVocabularyWordViewModelTests()
        {
            _screen = ModifyVocabularyWordScreen.ForNewWord()
                      .WithSpelling("spelling")
                      .WithPhrase("phrase")
                      .WithPronunciation("pronunciation");

            var application = new WordTutorApplication(_screen);

            _store  = new FakeApplicationStore(application);
            _logger = new FakeLogger();

            _model = new ModifyVocabularyWordViewModel(_store, _logger);
            _notifyPropertyChanged = new NotifyPropertyChangedProbe(_model);
            _store.ClearCapturedMessages();
        }
コード例 #6
0
 public ForExistingWord()
 {
     _screen = ModifyVocabularyWordScreen.ForExistingWord(_word);
 }