public async Task ReturnsTheEntityWithTheGivenId()
            {
                const long id     = 42;
                var        entity = new MockTimeEntry();

                DataSource.TimeEntries.GetById(id).Returns(Observable.Return(entity));

                var result = await InteractorFactory.GetTimeEntryById(id).Execute();

                result.Should().BeSameAs(entity);
            }
Beispiel #2
0
        public DeleteTimeEntryInteractorTests()
        {
            timeEntry = new MockTimeEntry
            {
                Id = 12
            };

            InteractorFactory.GetTimeEntryById(timeEntry.Id)
            .Execute()
            .Returns(Observable.Return(timeEntry));
            DataSource.TimeEntries.Update(Arg.Any <IThreadSafeTimeEntry>())
            .Returns(callInfo => Observable.Return(callInfo.Arg <IThreadSafeTimeEntry>()));

            interactor = new DeleteTimeEntryInteractor(TimeService, DataSource.TimeEntries, InteractorFactory, timeEntry.Id);
        }
            public async Task TracksTheTimeEntryEditedFromCalendarEventWhenStartTimeChanges()
            {
                var timeEntry = new MockTimeEntry
                {
                    Start    = calendarItem.StartTime.Add(TimeSpan.FromHours(1)),
                    Duration = (long)calendarItem.Duration.Value.TotalSeconds
                };

                InteractorFactory.GetTimeEntryById(Arg.Any <long>())
                .Execute()
                .Returns(Observable.Return(timeEntry));

                ViewModel.OnUpdateTimeEntry.Execute(calendarItem);

                AnalyticsService.TimeEntryChangedFromCalendar.Received().Track(CalendarChangeEvent.StartTime);
            }
Beispiel #4
0
        private EditTimeEntryDto prepareTest()
        {
            var observable = Observable.Return(timeEntry);

            InteractorFactory.GetTimeEntryById(Arg.Is(timeEntry.Id))
            .Execute()
            .Returns(observable);

            var dto = new EditTimeEntryDto
            {
                Id          = timeEntry.Id,
                Description = "New description",
                StartTime   = DateTimeOffset.UtcNow,
                ProjectId   = 13,
                Billable    = true,
                WorkspaceId = 71,
                TagIds      = new long[] { 1, 10, 34, 42 }
            };

            return(dto);
        }
Beispiel #5
0
        public void PropagatesErrorIfUpdateFails()
        {
            var failingTimeEntry = Models.TimeEntry.Builder.Create(12)
                                   .SetStart(now)
                                   .SetSyncStatus(SyncStatus.InSync)
                                   .SetDescription("")
                                   .SetUserId(11)
                                   .SetWorkspaceId(10)
                                   .SetAt(now)
                                   .Build();

            var timeEntryObservable = Observable.Return(failingTimeEntry);
            var errorObservable     = Observable.Throw <IThreadSafeTimeEntry>(new DatabaseOperationException <IDatabaseTimeEntry>(new Exception()));

            InteractorFactory.GetTimeEntryById(Arg.Is(timeEntry.Id))
            .Execute()
            .Returns(timeEntryObservable);
            DataSource.TimeEntries.Update(Arg.Any <IThreadSafeTimeEntry>()).Returns(errorObservable);
            var observer = Substitute.For <IObserver <Unit> >();

            interactor.Execute().Subscribe(observer);

            observer.Received().OnError(Arg.Any <DatabaseOperationException <IDatabaseTimeEntry> >());
        }