public async Task Navigate_UnregisteredView_ThrowInvalidOperationException() { var app = new PrismApplicationMock(); var navigationService = ResolveAndSetRootPage(app); var exception = await Assert.ThrowsAsync<NullReferenceException>(async () => await navigationService.NavigateAsync("missing")); Assert.Contains("missing", exception.Message, StringComparison.OrdinalIgnoreCase); }
public void Container_ResolveNavigationService() { var app = new PrismApplicationMock(); var navigationService = app.NavigationService; Assert.NotNull(navigationService); Assert.IsType<DryIocPageNavigationService>(navigationService); }
public void Module_Initialize() { var app = new PrismApplicationMock(); var module = app.Container.Resolve<ModuleMock>(); Assert.NotNull(module); Assert.True(module.Initialized); }
public void ResolveTypeRegisteredWithContainer() { var app = new PrismApplicationMock(); var service = app.Container.Resolve<IDryIocServiceMock>(); Assert.NotNull(service); Assert.IsType<DryIocServiceMock>(service); }
public void OnInitialized_SetPage() { var view = new ViewMock(); var app = new PrismApplicationMock(view); Assert.True(app.Initialized); Assert.NotNull(Application.Current.MainPage); Assert.Same(view, Application.Current.MainPage); }
public void ResolveTypeRegisteredWithDependencyService() { var app = new PrismApplicationMock(); // TODO(joacar) // Since we must call Xamarin.Forms.Init() (and cannot do so from PCL) // to call Xamarin.Forms.DependencyService // we check that this throws an InvalidOperationException (for reason stated above). // This shows that a call to Xamarin.Forms.DependencyService was made and thus should return // service instance (if registered) Assert.Throws<TargetInvocationException>( () => app.Container.Resolve<IDependencyServiceMock>(IfUnresolved.ReturnDefault)); }
public async Task Navigate_Key() { var app = new PrismApplicationMock(); var navigationService = ResolveAndSetRootPage(app); await navigationService.NavigateAsync("view"); var rootPage = ((IPageAware)navigationService).Page; Assert.True(rootPage.Navigation.ModalStack.Count == 1); Assert.IsType(typeof(ViewMock), rootPage.Navigation.ModalStack[0]); }
public void OnInitialized() { var app = new PrismApplicationMock(); Assert.True(app.Initialized); }
private static INavigationService ResolveAndSetRootPage(PrismApplicationMock app) { var navigationService = app.NavigationService; ((IPageAware)navigationService).Page = new ContentPage(); return navigationService; }
public void Container_ResolveByKey() { var app = new PrismApplicationMock(); var viewModel = app.Container.Resolve<ViewModelBMock>(ViewModelBMock.Key); Assert.NotNull(viewModel); Assert.IsType<ViewModelBMock>(viewModel); }
public void Navigate_ViewModelFactory_PageAware() { var app = new PrismApplicationMock(); var view = new AutowireView(); var viewModel = (AutowireViewModel)view.BindingContext; var pageAware = (IPageAware)viewModel.NavigationService; var navigationServicePage = app.CreateNavigationServiceForPage(view); Assert.IsType<AutowireView>(pageAware.Page); var navigatedPage = ((IPageAware)navigationServicePage).Page; Assert.IsType<AutowireView>(navigatedPage); Assert.Same(view, pageAware.Page); Assert.Same(pageAware.Page, navigatedPage); }