Example #1
0
            public async Task PropagatesCorrectTimeEntryStartOriginToAnalytics(ContinueTimeEntryMode continueMode)
            {
                var prototype = CreatePrototype(ValidTime, ValidDescription, true, ProjectId);

                await InteractorFactory.ContinueTimeEntry(prototype, continueMode).Execute();

                AnalyticsService.Received().Track(Arg.Is <StartTimeEntryEvent>(
                                                      ev => (int)ev.Origin == (int)continueMode && ev.Origin.ToString() == continueMode.ToString()));
            }
            public async ThreadingTask ExecutesTheContinueTimeEntryInteractor()
            {
                var mockedInteractor = Substitute.For <IInteractor <IObservable <IThreadSafeTimeEntry> > >();

                InteractorFactory.ContinueTimeEntry(Arg.Any <ITimeEntryPrototype>()).Returns(mockedInteractor);
                var timeEntryViewModel = createTimeEntryViewModel();

                await ViewModel.ContinueTimeEntryCommand.ExecuteAsync(timeEntryViewModel);

                await mockedInteractor.Received().Execute();
            }
            public void CannotBeExecutedTwiceInARow()
            {
                var timeEntryViewModel = createTimeEntryViewModel();
                var mockedInteractor   = Substitute.For <IInteractor <IObservable <IThreadSafeTimeEntry> > >();

                InteractorFactory.ContinueTimeEntry(Arg.Any <ITimeEntryPrototype>()).Returns(mockedInteractor);
                mockedInteractor.Execute()
                .Returns(Observable.Never <IThreadSafeTimeEntry>());

                ViewModel.ContinueTimeEntryCommand.ExecuteAsync(timeEntryViewModel);
                ViewModel.ContinueTimeEntryCommand.ExecuteAsync(timeEntryViewModel);

                InteractorFactory.Received(1).ContinueTimeEntry(timeEntryViewModel);
            }
            public async ThreadingTask CanBeExecutedForTheSecondTimeIfStartingTheFirstOneFinishesSuccessfully()
            {
                var timeEntryViewModel = createTimeEntryViewModel();
                var timeEntry          = Substitute.For <IThreadSafeTimeEntry>();
                var mockedInteractor   = Substitute.For <IInteractor <IObservable <IThreadSafeTimeEntry> > >();

                InteractorFactory.ContinueTimeEntry(Arg.Any <ITimeEntryPrototype>()).Returns(mockedInteractor);
                mockedInteractor.Execute()
                .Returns(Observable.Return(timeEntry));

                await ViewModel.ContinueTimeEntryCommand.ExecuteAsync(timeEntryViewModel);

                await ViewModel.ContinueTimeEntryCommand.ExecuteAsync(timeEntryViewModel);

                InteractorFactory.Received(2).ContinueTimeEntry(timeEntryViewModel);
            }
Example #5
0
        public async Task TracksTheTimeEntryContinuedEvent(ContinueTimeEntryMode continueMode, ContinueTimeEntryOrigin expectedOrigin)
        {
            InteractorFactory
            .ContinueTimeEntry(Arg.Any <ITimeEntryPrototype>(), Arg.Any <ContinueTimeEntryMode>())
            .Execute()
            .Returns(Observable.Return(createdTimeEntry));

            var interactor = new ContinueTimeEntryFromMainLogInteractor(
                InteractorFactory,
                AnalyticsService,
                timeEntryPrototype,
                continueMode,
                IndexInLog,
                DayInLog,
                DaysInPast);

            await interactor.Execute();

            AnalyticsService
            .Received()
            .TimeEntryContinued
            .Track(expectedOrigin, IndexInLog, DayInLog, DaysInPast);
        }
Example #6
0
 protected override IObservable <IDatabaseTimeEntry> CallInteractor(ITimeEntryPrototype prototype)
 => InteractorFactory.ContinueTimeEntry(prototype).Execute();