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 void ViewSessionCommand_NavigatesToSession()
        {
            var sponsor = new Sponsor { Id = 42 };
            var viewModel = new SponsorsViewModel(Messenger, CodeCampService);

            viewModel.ViewSponsorCommand.Execute(sponsor);

            Assert.AreEqual(1, Dispatcher.ShowViewModelRequests.Count);

            var request = Dispatcher.ShowViewModelRequests.Single();
            var navParameters = request.ParameterValues.Read(typeof(SponsorViewModel.NavigationParameters)) as SponsorViewModel.NavigationParameters;
            Assert.NotNull(navParameters);
            Assert.AreEqual(sponsor.Id, navParameters.Id);
        }
        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);
        }
Example #4
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();
        }