Пример #1
0
            public void FiresACallToLoadReports(DateTimeOffset now)
            {
                var date = now.Date;

                TimeService.CurrentDateTime.Returns(now);
                var expectedStartDate = date.AddDays(1 - (int)date.DayOfWeek);

                ViewModel.Prepare(WorkspaceId);

                ViewModel.Initialize().Wait();

                ReportsProvider.Received().GetProjectSummary(
                    WorkspaceId, expectedStartDate, expectedStartDate.AddDays(6));
            }
            public async Task ShouldTriggerReloadForEveryAppearance(int numberOfAppearances)
            {
                TimeService.CurrentDateTime.Returns(DateTimeOffset.Now);
                ReportsProvider.GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(),
                                                  Arg.Any <DateTimeOffset>())
                .ReturnsForAnyArgs(Observable.Empty <ProjectSummaryReport>(SchedulerProvider.TestScheduler));
                await ViewModel.Initialize();

                ViewModel.ViewAppeared(); // First call is skipped

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

                ReportsProvider.Received(numberOfAppearances).GetProjectSummary(Arg.Any <long>(), Arg.Any <DateTimeOffset>(),
                                                                                Arg.Any <DateTimeOffset>());
            }
            public async Task ShouldTriggerAReportReload()
            {
                TimeService.CurrentDateTime.Returns(DateTimeOffset.Now);
                await ViewModel.Initialize();

                TestScheduler.Start();

                var mockWorkspace = new MockWorkspace {
                    Id = WorkspaceId + 1
                };

                DialogService.Select(Arg.Any <string>(), Arg.Any <IEnumerable <(string, IThreadSafeWorkspace)> >(), Arg.Any <int>())
                .Returns(Observable.Return(mockWorkspace));

                ViewModel.SelectWorkspace.Execute();
                TestScheduler.Start();

                await ReportsProvider.Received().GetProjectSummary(Arg.Is(mockWorkspace.Id), Arg.Any <DateTimeOffset>(),
                                                                   Arg.Any <DateTimeOffset>());
            }