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, });
public void Create_WhenGivenScreen_ReturnsExpectedViewModel() { var screen = ModifyVocabularyWordScreen.ForNewWord(); var viewModel = _factory.Create(screen); viewModel.Should().NotBeNull(); viewModel.Should().BeOfType <ModifyVocabularyWordViewModel>(); }
public void WhenScreenConfigured_ReturnsExpectedWord() { var screen = ModifyVocabularyWordScreen.ForNewWord() .WithSpelling(_word.Spelling) .WithPronunciation(_word.Pronunciation) .WithPhrase(_word.Phrase); screen.AsWord().Should().Be(_word); }
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(); }
public ForExistingWord() { _screen = ModifyVocabularyWordScreen.ForExistingWord(_word); }