public UpdateMultipleTimeEntriesInteractorTests() { int count = 8; timeEntries = new IThreadSafeTimeEntry[count]; for (int i = 0; i < 8; i++) { timeEntries[i] = Models.TimeEntry.Builder .Create(i + 10) .SetUserId(10) .SetDescription($"Description {i + 1}") .SetWorkspaceId(11) .SetSyncStatus(SyncStatus.InSync) .SetAt(now.AddDays(-1)) .SetStart(now.AddHours(-2)) .Build(); } var observable = Observable.Return(timeEntries); timeEntriesSource = Substitute.For <ITimeEntriesSource>(); DataSource.TimeEntries.Returns(timeEntriesSource); timeEntriesSource.GetByIds(Arg.Any <long[]>()).Returns(observable); }
public GetTimeEntriesAutocompleteSuggestions(ITimeEntriesSource dataSource, IList <string> wordsToQuery) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(wordsToQuery, nameof(wordsToQuery)); this.dataSource = dataSource; this.wordsToQuery = wordsToQuery; }
public DeleteOldEntriesState(ITimeService timeService, ITimeEntriesSource dataSource) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); Ensure.Argument.IsNotNull(timeService, nameof(timeService)); this.dataSource = dataSource; this.timeService = timeService; }
public DeleteNonReferencedProjectGhostsState(IProjectsSource projectsDataSource, ITimeEntriesSource timeEntriesDataSource) { Ensure.Argument.IsNotNull(projectsDataSource, nameof(projectsDataSource)); Ensure.Argument.IsNotNull(timeEntriesDataSource, nameof(timeEntriesDataSource)); this.projectsDataSource = projectsDataSource; this.timeEntriesDataSource = timeEntriesDataSource; }
public DeleteTimeEntryInteractor( ITimeEntriesSource dataSource, long id) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dataSource = dataSource; this.id = id; }
public ObserveTimeTrackedTodayInteractor( ITimeService timeService, ITimeEntriesSource timeEntries) { Ensure.Argument.IsNotNull(timeService, nameof(timeService)); Ensure.Argument.IsNotNull(timeEntries, nameof(timeEntries)); this.timeService = timeService; this.timeEntries = timeEntries; }
public GetCalendarItemsForDateInteractor( ITimeEntriesSource timeEntriesDataSource, ICalendarService calendarService, IUserPreferences userPreferences, DateTime date) { Ensure.Argument.IsNotNull(timeEntriesDataSource, nameof(timeEntriesDataSource)); Ensure.Argument.IsNotNull(calendarService, nameof(calendarService)); Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences)); Ensure.Argument.IsNotNull(date, nameof(date)); this.timeEntriesDataSource = timeEntriesDataSource; this.calendarService = calendarService; this.userPreferences = userPreferences; this.date = date; }
private async void sync(ISyncManager syncManager, ITimeEntriesSource timeEntries) { var numberOfSyncedTimeEntries = 0; // To ignore time entries created/updated in the app it is enough to filter out all the ones which need sync. // There is still a problem with the entities which are created in the app and are immediately pushed // during the initial sync. I think it's OK to include these for the time being and re-evaluate this // decision once we collect some data. var subscription = Observable.Merge( timeEntries.Created.Where(timeEntry => timeEntry.SyncStatus == SyncStatus.InSync).SelectUnit(), timeEntries.Updated.Where(update => update.Entity.SyncStatus == SyncStatus.InSync).SelectUnit(), timeEntries.Deleted.SelectUnit()) .Subscribe(_ => numberOfSyncedTimeEntries++); await syncManager.ForceFullSync(); subscription.Dispose(); analyticsService.NumberOfSyncedTimeEntriesWhenResumingTheAppFromBackground.Track(numberOfSyncedTimeEntries); }
private void setupTest() { ids = new long[] { 4, 8, 15, 16, 23, 42 }; interactorFactory = Substitute.For <IInteractorFactory>(); var teInteractor = Substitute.For <IInteractor <IObservable <IEnumerable <IThreadSafeTimeEntry> > > >(); var workspace = Substitute.For <IThreadSafeWorkspace>(); var tes = Enumerable.Range(0, 5) .Select((_, index) => new MockTimeEntry(index, workspace)) .ToList(); var observable = Observable.Return(tes); teInteractor.Execute().Returns(observable); dataSource = Substitute.For <ITimeEntriesSource>(); DataSource.TimeEntries.Returns(dataSource); interactorFactory .GetMultipleTimeEntriesById(Arg.Any <long[]>()) .Returns(teInteractor); testedInteractor = new SoftDeleteMultipleTimeEntriesInteractor(DataSource.TimeEntries, SyncManager, interactorFactory, ids); }
public DeleteInaccessibleTimeEntriesState(ITimeEntriesSource dataSource) { Ensure.Argument.IsNotNull(dataSource, nameof(dataSource)); this.dataSource = dataSource; }