public async void Init_DataLoadsSuccessfully_LoadsTimeSlots()
        {
            var session = new Session {
                StartTime = DateTime.Now, EndTime = DateTime.Now, Id = 42, SpeakerId = 1
            };
            var data = new CampData
            {
                Sessions = new List <Session> {
                    session
                },
                Speakers = new List <Speaker> {
                    new Speaker {
                        Id = 1
                    }
                },
            };

            DataClient.GetDataBody = () => Task.FromResult(data);
            var viewModel = new SessionsViewModel(Messenger, CodeCampService);

            Assert.True(viewModel.IsLoading);

            await viewModel.Init();

            Assert.AreEqual(1, viewModel.TimeSlots.Count);

            var slot = viewModel.TimeSlots.First();

            Assert.AreEqual(session.StartTime, slot.StartTime);
            Assert.AreEqual(session.EndTime, slot.EndTime);
            Assert.AreEqual(1, slot.Sessions.Count);
            Assert.AreEqual(session, slot.Sessions.First());
            Assert.False(viewModel.IsLoading);
        }
示例#2
0
        private void reinitializeChildViewModels()
        {
            OverviewViewModel = new OverviewViewModel(Messenger, _campService);
            OverviewViewModel.Init();

            SessionsViewModel = new SessionsViewModel(Messenger, _campService);
            SessionsViewModel.Init();

            SpeakersViewModel = new SpeakersViewModel(Messenger, _campService);
            SpeakersViewModel.Init();

            SponsorsViewModel = new SponsorsViewModel(Messenger, _campService);
            SponsorsViewModel.Init();
        }
        public async void Init_ExceptionThrown_ReportsError()
        {
            DataClient.GetDataBody = delegate { throw new Exception(); };
            string errorMessage = null;

            Messenger.Subscribe <ErrorMessage>(msg => errorMessage = msg.Message);

            var viewModel = new SessionsViewModel(Messenger, CodeCampService);
            await viewModel.Init();

            Assert.NotNull(errorMessage);
            Assert.False(viewModel.IsLoading);
            Assert.Null(viewModel.TimeSlots);
        }