Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 public void Container_ResolveNavigationService()
 {
     var app = new PrismApplicationMock();
     var navigationService = app.NavigationService;
     Assert.NotNull(navigationService);
     Assert.IsType<DryIocPageNavigationService>(navigationService);
 }
Esempio n. 3
0
 public void Module_Initialize()
 {
     var app = new PrismApplicationMock();
     var module = app.Container.Resolve<ModuleMock>();
     Assert.NotNull(module);
     Assert.True(module.Initialized);
 }
Esempio n. 4
0
 public void ResolveTypeRegisteredWithContainer()
 {
     var app = new PrismApplicationMock();
     var service = app.Container.Resolve<IDryIocServiceMock>();
     Assert.NotNull(service);
     Assert.IsType<DryIocServiceMock>(service);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 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));
 }
Esempio n. 7
0
 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]);
 }
Esempio n. 8
0
 public void OnInitialized()
 {
     var app = new PrismApplicationMock();
     Assert.True(app.Initialized);
 }
Esempio n. 9
0
 private static INavigationService ResolveAndSetRootPage(PrismApplicationMock app)
 {
     var navigationService = app.NavigationService;
     ((IPageAware)navigationService).Page = new ContentPage();
     return navigationService;
 }
Esempio n. 10
0
 public void Container_ResolveByKey()
 {
     var app = new PrismApplicationMock();
     var viewModel = app.Container.Resolve<ViewModelBMock>(ViewModelBMock.Key);
     Assert.NotNull(viewModel);
     Assert.IsType<ViewModelBMock>(viewModel);
 }
Esempio n. 11
0
 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);
 }