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<AutofacPageNavigationService>(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<IAutofacServiceMock>(); Assert.NotNull(service); Assert.IsType<AutofacServiceMock>(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 // 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<ComponentNotRegisteredException>( () => app.Container.Resolve<IDependencyServiceMock>()); }
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.ResolveNamed<ViewModelBMock>(ViewModelBMock.Key); Assert.NotNull(viewModel); Assert.IsType<ViewModelBMock>(viewModel); }
public void Container_ResolveByType() { var app = new PrismApplicationMock(); var viewModel = app.Container.Resolve<ViewModelAMock>(); Assert.NotNull(viewModel); Assert.IsType<ViewModelAMock>(viewModel); }