Example #1
0
            public async Task ShouldTriggerReloadForEveryAppearanceAfterSignificantTimePassed(int numberOfAppearances)
            {
                var timeService = new TimeService(TestScheduler);

                TestScheduler.AdvanceTo(DateTimeOffset.Now.Ticks);

                InteractorFactory
                .GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset?>())
                .Returns(Interactor);

                var viewModel = new ReportsViewModel(
                    DataSource,
                    timeService,
                    NavigationService,
                    InteractorFactory,
                    AnalyticsService,
                    SchedulerProvider,
                    RxActionFactory
                    );

                Interactor.Execute()
                .ReturnsForAnyArgs(Observable.Empty <ProjectSummaryReport>(SchedulerProvider.TestScheduler));
                await viewModel.Initialize();

                viewModel.CalendarViewModel.ViewAppeared();
                InteractorFactory.ClearReceivedCalls();

                for (int i = 0; i < numberOfAppearances; ++i)
                {
                    viewModel.ViewDisappeared();
                    TestScheduler.AdvanceBy(TimeSpan.FromSeconds(5).Ticks);
                    viewModel.ViewAppeared();
                }

                TestScheduler.Start();

                InteractorFactory
                .Received(numberOfAppearances)
                .GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>());
            }
            public void SetsTheEnabledCalendarsWhenThereAreCalendars(NonEmptyString[] nonEmptyStrings)
            {
                if (nonEmptyStrings == null)
                {
                    return;
                }

                InteractorFactory.ClearReceivedCalls();
                var viewModel = CreateViewModel();

                var calendarIds = nonEmptyStrings.Select(str => str.Get).ToArray();

                NavigationService.Navigate <SelectUserCalendarsViewModel, bool, string[]>(Arg.Any <bool>()).Returns(calendarIds);
                PermissionsService.RequestCalendarAuthorization().Returns(Observable.Return(true));
                InteractorFactory.GetUserCalendars().Execute().Returns(
                    Observable.Return(new UserCalendar[] { new UserCalendar() })
                    );

                viewModel.GetStartedAction.Execute(Unit.Default).Wait();

                InteractorFactory.Received().SetEnabledCalendars(calendarIds).Execute();
            }
Example #3
0
            public async Task ShouldNotTriggerReloadAfterDisappearingAndAppearingImmediately(int numberOfAppearances)
            {
                TimeService.CurrentDateTime.Returns(DateTimeOffset.Now);
                Interactor.Execute()
                .ReturnsForAnyArgs(Observable.Empty <ProjectSummaryReport>(SchedulerProvider.TestScheduler));
                await ViewModel.Initialize();

                ViewModel.CalendarViewModel.ViewAppeared();
                InteractorFactory.ClearReceivedCalls();

                for (int i = 0; i < numberOfAppearances; ++i)
                {
                    ViewModel.ViewDisappeared();
                    ViewModel.ViewAppeared();
                }

                TestScheduler.Start();

                InteractorFactory
                .DidNotReceive()
                .GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(), Arg.Any <DateTimeOffset>());
            }
Example #4
0
            public void SetsTheEnabledCalendarsWhenThereAreCalendars(NonEmptyString[] nonEmptyStrings)
            {
                if (nonEmptyStrings == null)
                {
                    return;
                }

                InteractorFactory.ClearReceivedCalls();
                var viewModel = CreateViewModel();

                viewModel.AttachView(View);
                var calendarIds = nonEmptyStrings.Select(str => str.Get).ToArray();

                NavigationService.Navigate <SelectUserCalendarsViewModel, bool, string[]>(Arg.Any <bool>(), viewModel.View).Returns(calendarIds);
                View.RequestCalendarAuthorization().Returns(Observable.Return(true));
                InteractorFactory.GetUserCalendars().Execute().Returns(
                    Observable.Return(new UserCalendar[] { new UserCalendar() })
                    );

                viewModel.SelectCalendars.Execute();
                TestScheduler.Start();

                InteractorFactory.Received().SetEnabledCalendars(calendarIds).Execute();
            }