public async Task UpdatesTheDurationFormatProperty() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var oldPreferences = new MockPreferences { DurationFormat = oldDurationFormat }; var newPreferences = new MockPreferences { DurationFormat = newDurationFormat }; PreferencesSubject.OnNext(oldPreferences); NavigationService .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(Arg.Any <DurationFormat>(), View) .Returns(Task.FromResult(newDurationFormat)); InteractorFactory .UpdatePreferences(Arg.Any <EditPreferencesDTO>()) .Execute() .Returns(Observable.Return(newPreferences)); ViewModel.SelectDurationFormat.Execute(); TestScheduler.Start(); await InteractorFactory .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.DurationFormat.ValueOr(oldDurationFormat) == newDurationFormat)) .Received() .Execute(); }
public async Task UpdatesTheDurationFormatProperty() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var oldPreferences = new MockPreferences { DurationFormat = oldDurationFormat }; var newPreferences = new MockPreferences { DurationFormat = newDurationFormat }; PreferencesSubject.OnNext(oldPreferences); NavigationService .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(Arg.Any <DurationFormat>()) .Returns(Task.FromResult(newDurationFormat)); DataSource .Preferences .Update(Arg.Any <EditPreferencesDTO>()) .Returns(Observable.Return(newPreferences)); await ViewModel.SelectDurationFormat(); await DataSource.Preferences.Received() .Update(Arg.Is <EditPreferencesDTO>(dto => dto.DurationFormat.ValueOr(oldDurationFormat) == newDurationFormat)); }
public async Task UpdatesTheDateFormatProperty() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var oldPreferences = new MockPreferences { DateFormat = oldDateFormat }; var newPreferences = new MockPreferences { DateFormat = newDateFormat }; PreferencesSubject.OnNext(oldPreferences); NavigationService .Navigate <SelectDateFormatViewModel, DateFormat, DateFormat>(Arg.Any <DateFormat>(), View) .Returns(Task.FromResult(newDateFormat)); InteractorFactory.UpdatePreferences(Arg.Any <EditPreferencesDTO>()) .Execute() .Returns(Observable.Return(newPreferences)); ViewModel.SelectDateFormat.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.DateFormat.ValueOr(oldDateFormat) == newDateFormat)) .Execute(); }
public async Task UpdatesTheDateFormatProperty() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var oldPreferences = new MockPreferences { DateFormat = oldDateFormat }; var newPreferences = new MockPreferences { DateFormat = newDateFormat }; PreferencesSubject.OnNext(oldPreferences); NavigationService .Navigate <SelectDateFormatViewModel, DateFormat, DateFormat>(Arg.Any <DateFormat>()) .Returns(Task.FromResult(newDateFormat)); DataSource .Preferences .Update(Arg.Any <EditPreferencesDTO>()) .Returns(Observable.Return(newPreferences)); await ViewModel.SelectDateFormat(); await DataSource.Preferences.Received() .Update(Arg.Is <EditPreferencesDTO>(dto => dto.DateFormat.ValueOr(oldDateFormat) == newDateFormat)); }
public async Task ChangesTheValueOfTheUseTwentyFourHourHourClock(bool originalValue) { var timeFormat = originalValue ? TimeFormat.TwentyFourHoursFormat : TimeFormat.TwelveHoursFormat; PreferencesSubject.OnNext(new MockPreferences { TimeOfDayFormat = timeFormat }); await ViewModel.ToggleUseTwentyFourHourClock(); await DataSource.Preferences.Received().Update(Arg.Is <EditPreferencesDTO>( dto => dto.TimeOfDayFormat.ValueOr(default(TimeFormat)).IsTwentyFourHoursFormat != originalValue)); }
public async Task InitiatesPushSync() { var preferences = new MockPreferences(); PreferencesSubject.OnNext(preferences); var observable = Observable.Return(preferences); DataSource.Preferences.Update(Arg.Any <EditPreferencesDTO>()).Returns(observable); await ViewModel.ToggleUseTwentyFourHourClock(); await DataSource.SyncManager.Received().PushSync(); }
public async Task InitiatesPushSync() { var oldValue = false; var preferences = new MockPreferences { CollapseTimeEntries = oldValue }; PreferencesSubject.OnNext(preferences); ViewModel.ToggleTimeEntriesGrouping.Execute(); TestScheduler.Start(); await SyncManager.Received().PushSync(); }
public async Task InitiatesPushSync() { var preferences = new MockPreferences(); PreferencesSubject.OnNext(preferences); var observable = Observable.Return(preferences); InteractorFactory.UpdatePreferences(Arg.Any <EditPreferencesDTO>()).Execute().Returns(observable); ViewModel.ToggleTwentyFourHourSettings.Execute(); TestScheduler.Start(); SyncManager.Received().PushSync(); }
public async Task NavigatesToSelectDurationFormatViewModelPassingCurrentDurationFormat() { var durationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = durationFormat }; PreferencesSubject.OnNext(preferences); await ViewModel.SelectDurationFormat(); await NavigationService .Received() .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(durationFormat); }
public async Task NavigatesToSelectDateFormatViewModelPassingCurrentDateFormat() { var dateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var preferences = new MockPreferences { DateFormat = dateFormat }; PreferencesSubject.OnNext(preferences); await ViewModel.SelectDateFormat(); await NavigationService .Received() .Navigate <SelectDateFormatViewModel, DateFormat, DateFormat>(dateFormat); }
public void TracksEventWhenToggled(bool initialState) { var analyticsEvent = Substitute.For <IAnalyticsEvent <bool> >(); AnalyticsService.GroupTimeEntriesSettingsChanged.Returns(analyticsEvent); var preferences = new MockPreferences { CollapseTimeEntries = initialState }; var expectedState = !initialState; PreferencesSubject.OnNext(preferences); ViewModel.ToggleTimeEntriesGrouping.Execute(); TestScheduler.Start(); analyticsEvent.Received().Track(expectedState); }
public async Task InitiatesPushSync() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var preferences = new MockPreferences { DateFormat = oldDateFormat }; PreferencesSubject.OnNext(preferences); NavigationService .Navigate <SelectDateFormatViewModel, DateFormat, DateFormat>(Arg.Any <DateFormat>()) .Returns(Task.FromResult(newDateFormat)); await ViewModel.SelectDateFormat(); await DataSource.SyncManager.Received().PushSync(); }
public async Task ChangesTheValueOfTheUseTwentyFourHourHourClock(bool originalValue) { var timeFormat = originalValue ? TimeFormat.TwentyFourHoursFormat : TimeFormat.TwelveHoursFormat; PreferencesSubject.OnNext(new MockPreferences { TimeOfDayFormat = timeFormat }); ViewModel.ToggleTwentyFourHourSettings.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>( dto => dto.TimeOfDayFormat.ValueOr(default(TimeFormat)).IsTwentyFourHoursFormat != originalValue) ).Execute(); }
public async Task SelectDurationFormatCommandCallsPushSync() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = oldDurationFormat }; PreferencesSubject.OnNext(preferences); NavigationService .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(Arg.Any <DurationFormat>()) .Returns(Task.FromResult(newDurationFormat)); ViewModel.SelectDurationFormat.Execute(); TestScheduler.Start(); await SyncManager.Received().PushSync(); }
public async Task UpdatesTheStoredPreferences() { var oldValue = false; var newValue = true; var preferences = new MockPreferences { CollapseTimeEntries = oldValue }; PreferencesSubject.OnNext(preferences); ViewModel.ToggleTimeEntriesGrouping.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.CollapseTimeEntries.Equals(New <bool> .Value(newValue)))) .Execute(); }
public async Task ShowsASelectDialogPassingTheCurrentDateFormat() { var dateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var preferences = new MockPreferences { DateFormat = dateFormat }; PreferencesSubject.OnNext(preferences); ViewModel.SelectDateFormat.Execute(); TestScheduler.Start(); await View .Received() .Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DateFormat> > >(), Arg.Is(2)); }
public async Task NavigatesToSelectDurationFormatViewModelPassingCurrentDurationFormat() { var durationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = durationFormat }; PreferencesSubject.OnNext(preferences); ViewModel.SelectDurationFormat.Execute(); TestScheduler.Start(); await View .Received() .Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DurationFormat> > >(), Arg.Is(1)); }
public async Task SelectDurationFormatCommandCallsPushSync() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = oldDurationFormat }; PreferencesSubject.OnNext(preferences); NavigationService .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(Arg.Any <DurationFormat>()) .Returns(Task.FromResult(newDurationFormat)); var syncManager = Substitute.For <ISyncManager>(); DataSource.SyncManager.Returns(syncManager); await ViewModel.SelectDurationFormat(); await syncManager.Received().PushSync(); }
public async Task UpdatesTheStoredPreferences() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = oldDurationFormat }; PreferencesSubject.OnNext(preferences); NavigationService .Navigate <SelectDurationFormatViewModel, DurationFormat, DurationFormat>(Arg.Any <DurationFormat>()) .Returns(Task.FromResult(newDurationFormat)); await ViewModel.SelectDurationFormat(); await DataSource .Preferences .Received() .Update(Arg.Is <EditPreferencesDTO>(dto => dto.DurationFormat.Equals(New <DurationFormat> .Value(newDurationFormat)))); }
public async Task InitiatesPushSync() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var preferences = new MockPreferences { DateFormat = oldDateFormat }; PreferencesSubject.OnNext(preferences); View.Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DateFormat> > >(), Arg.Any <int>()) .Returns(Observable.Return(newDateFormat)); ViewModel.SelectDateFormat.Execute(); TestScheduler.Start(); SyncManager.Received().PushSync(); }
public async Task SelectDurationFormatCommandCallsPushSync() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = oldDurationFormat }; PreferencesSubject.OnNext(preferences); View.Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DurationFormat> > >(), Arg.Any <int>()) .Returns(Observable.Return(newDurationFormat)); ViewModel.SelectDurationFormat.Execute(); TestScheduler.Start(); await SyncManager.Received().PushSync(); }
public async Task UpdatesTheStoredPreferences() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var preferences = new MockPreferences { DateFormat = oldDateFormat }; PreferencesSubject.OnNext(preferences); NavigationService .Navigate <SelectDateFormatViewModel, DateFormat, DateFormat>(Arg.Any <DateFormat>()) .Returns(Task.FromResult(newDateFormat)); await ViewModel.SelectDateFormat(); await DataSource .Preferences .Received() .Update(Arg.Is <EditPreferencesDTO>(dto => dto.DateFormat.Equals(New <DateFormat> .Value(newDateFormat)))); }
public async Task UpdatesTheStoredPreferences() { var oldDateFormat = DateFormat.FromLocalizedDateFormat("MM-DD-YYYY"); var newDateFormat = DateFormat.FromLocalizedDateFormat("DD.MM.YYYY"); var preferences = new MockPreferences { DateFormat = oldDateFormat }; PreferencesSubject.OnNext(preferences); View.Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DateFormat> > >(), Arg.Any <int>()) .Returns(Observable.Return(newDateFormat)); ViewModel.SelectDateFormat.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.DateFormat.Equals(New <DateFormat> .Value(newDateFormat)))) .Execute(); }
public async Task UpdatesTheStoredPreferences() { var oldDurationFormat = DurationFormat.Decimal; var newDurationFormat = DurationFormat.Improved; var preferences = new MockPreferences { DurationFormat = oldDurationFormat }; PreferencesSubject.OnNext(preferences); View.Select( Arg.Any <string>(), Arg.Any <IEnumerable <SelectOption <DurationFormat> > >(), Arg.Any <int>()) .Returns(Observable.Return(newDurationFormat)); ViewModel.SelectDurationFormat.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.DurationFormat.Equals(New <DurationFormat> .Value(newDurationFormat)))) .Execute(); }
public async Task UpdatesTheCollapseTimeEntriesProperty() { var oldValue = false; var newValue = true; var oldPreferences = new MockPreferences { CollapseTimeEntries = oldValue }; var newPreferences = new MockPreferences { CollapseTimeEntries = newValue }; PreferencesSubject.OnNext(oldPreferences); InteractorFactory.UpdatePreferences(Arg.Any <EditPreferencesDTO>()) .Execute() .Returns(Observable.Return(newPreferences)); ViewModel.ToggleTimeEntriesGrouping.Execute(); TestScheduler.Start(); await InteractorFactory .Received() .UpdatePreferences(Arg.Is <EditPreferencesDTO>(dto => dto.CollapseTimeEntries.ValueOr(oldValue) == newValue)) .Execute(); }
public TheSwipeActionsToggle() { PreferencesSubject.OnNext(new MockPreferences()); }
public TheToggleManualModeMethod() { PreferencesSubject.OnNext(new MockPreferences()); }