コード例 #1
0
            public async Task EmitsFalseWhenThereAreNoCalendarsEnabledThenTrueWhenThereAreCalendarsEnabled()
            {
                var calendars = TestScheduler.CreateHotObservable(
                    new Recorded <Notification <List <string> > >(100, Notification.CreateOnNext(new List <string>())),
                    new Recorded <Notification <List <string> > >(200, Notification.CreateOnNext(new List <string> {
                    "nice event"
                })));

                UserPreferences.EnabledCalendars.Returns(calendars);
                PermissionsChecker.CalendarPermissionGranted.Returns(Observable.Return(true));
                var observer  = TestScheduler.CreateObserver <bool>();
                var viewModel = CreateViewModel();

                viewModel.HasCalendarsLinked.Subscribe(observer);

                await viewModel.Initialize();

                TestScheduler.Start();
                viewModel.ViewAppeared();
                TestScheduler.Start();

                UserPreferences.EnabledCalendars.Returns(Observable.Return(new List <string> {
                    "nice event"
                }));
                TestScheduler.Start();

                observer.Messages.AssertEqual(
                    ReactiveTest.OnNext(100, false),
                    ReactiveTest.OnNext(200, true)
                    );
            }