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 SponsorsViewModel(Messenger, CodeCampService); await viewModel.Init(); Assert.NotNull(errorMessage); Assert.False(viewModel.IsLoading); Assert.Null(viewModel.SponsorTiers); }
public async void Init_DataLoadsSuccessfully_LoadsSponsorList() { var sponsor = new Sponsor {Name = "Sponsor", Tier = "Gold"}; var data = new CampData { Sponsors = new List<Sponsor> { sponsor } }; DataClient.GetDataBody = () => Task.FromResult(data); var viewModel = new SponsorsViewModel(Messenger, CodeCampService); Assert.True(viewModel.IsLoading); await viewModel.Init(); //Assert.AreEqual(data.Sponsors, viewModel.Sponsors); Assert.AreEqual(1, viewModel.SponsorTiers.Count); Assert.AreEqual(1, viewModel.SponsorTiers.First().Sponsors.Count); Assert.AreEqual(sponsor, viewModel.SponsorTiers.First().Sponsors.First()); Assert.False(viewModel.IsLoading); }
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(); }