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();
            }
Ejemplo n.º 2
0
            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();
            }
Ejemplo n.º 4
0
            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();
            }
Ejemplo n.º 7
0
            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();
            }
Ejemplo n.º 8
0
            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);
            }
Ejemplo n.º 10
0
            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);
            }
Ejemplo n.º 11
0
            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);
            }
Ejemplo n.º 12
0
            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();
            }
Ejemplo n.º 13
0
            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();
            }
Ejemplo n.º 14
0
            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();
            }
Ejemplo n.º 15
0
            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();
            }
Ejemplo n.º 16
0
            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));
            }
Ejemplo n.º 17
0
            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));
            }
Ejemplo n.º 18
0
            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();
            }
Ejemplo n.º 19
0
            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))));
            }
Ejemplo n.º 20
0
            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();
            }
Ejemplo n.º 21
0
            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();
            }
Ejemplo n.º 22
0
            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))));
            }
Ejemplo n.º 23
0
            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();
            }
Ejemplo n.º 24
0
            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();
            }
Ejemplo n.º 25
0
            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();
            }
Ejemplo n.º 26
0
 public TheSwipeActionsToggle()
 {
     PreferencesSubject.OnNext(new MockPreferences());
 }
Ejemplo n.º 27
0
 public TheToggleManualModeMethod()
 {
     PreferencesSubject.OnNext(new MockPreferences());
 }