Example #1
0
        public async Task LaunchApplication()
        {
            // The App class does this work in the actual client
            // including initializing the singleton-lifestyle LoginWorkflowController with Navigation
            // (see QTB3.Client.LabResultPatterns.Common/App.xaml.cs)

            // We overload the DI to
            // -- set up a test HttpClient to be used by the client application service
            // -- set up in-memory test services that runs the read and write services
            // -- set up a TestLrpNavigator that runs the page lifecycle OnAppearing calls
            //
            // Note that the ASP.NET Startup used for in this testbench alters
            // -- the rest basepath,
            // -- authorization
            //        -- use local JWT token generation rather than Azure AD B2C
            //        -- for now, bypass gathering credentials and just issue token
            // -- uses the in-memory Sqlite dB

            var builder = new ContainerBuilder();

            builder.RegisterModule <MainModule>();
            builder.RegisterModule <Services2Module>();
            builder.RegisterModule <TestFactorsModule>();
            var container = builder.Build();

            // the test token manager can be induced to ask for relogin as if the token has expired
            _jwtTokenManager = container.Resolve <IJwtTokenManager>() as TestJwtTokenManager;

            // get the MainPage from the container
            // and wrap it in a NavigationPage, just as the App does...
            _mainPage = container.Resolve <IMainPage>() as MainPage;
            var navMainPage = new NavigationPage(_mainPage);

            // assign the navigation proxy
            Navigation = new TestLrpNavigation(_mainPage.Navigation);

            _loginPageController = container.Resolve <ILoginPageController>
                                   (
                new NamedParameter("navigation", Navigation),
                new NamedParameter("mainPage", _mainPage)
                                   );

            var mainPageViewModel = container.Resolve <IMainPageViewModel>
                                    (
                new NamedParameter("pageTitle", LrpConstants.MainPageTitle)
                                    );

            _mainPage.BindingContext = mainPageViewModel;
            _mainPageController      = container.Resolve <IMainPageController>
                                       (
                new NamedParameter("mainPage", _mainPage),
                new NamedParameter("mainPageViewModel", mainPageViewModel),
                new NamedParameter("navigation", Navigation)
                                       );

            // launch the main page
            await _mainPage.OnAppearingAsync();
        }
        public async Task BuildAddAsync(ILrpNavigation navigation)
        {
            var itemViewModel = _createItemViewModel();
            var itemPage      = _createItemPage();

            itemPage.InitializePage();
            itemPage.BindingContext = itemViewModel;
            var itemPageController = _createItemPageController(navigation, itemViewModel, itemPage);
            await itemPageController.InitializeAddAsync();

            await navigation.PushAsync(itemPage as ContentPage);
        }
        public async Task BuildEditAsync(ILrpNavigation navigation, TItem item)
        {
            var itemViewModel = _createItemViewModel();
            var itemPage      = _createItemPage();

            itemPage.InitializePage();
            itemPage.BindingContext = itemViewModel;
            var itemPageController = _createItemPageController(navigation, itemViewModel, itemPage);
            // COULD THROW
            await itemPageController.InitializeEditAsync(item);

            await navigation.PushAsync(itemPage as ContentPage);
        }
        public ItemPageController
        (
            ILrpNavigation navigation,
            IItemViewModel <TItem> viewModel,
            IItemPage <TItem> page
        )
        {
            _navigation = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _viewModel  = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
            _page       = page ?? throw new ArgumentNullException(nameof(page));

            WirePage();
        }
 public CollectionPageController
 (
     ILrpNavigation navigation,
     ICollectionPageViewModel <TItem> collectionPageViewModel,
     ICollectionPage <TItem> collectionPage,
     IItemMvcBuilder <TItem> itemMvcBuilder
 )
 {
     _navigation = navigation ?? throw new ArgumentNullException(nameof(navigation));
     _collectionPageViewModel = collectionPageViewModel ?? throw new ArgumentNullException(nameof(collectionPageViewModel));
     _collectionPage          = collectionPage ?? throw new ArgumentNullException(nameof(collectionPage));
     _itemMvcBuilder          = itemMvcBuilder ?? throw new ArgumentNullException(nameof(itemMvcBuilder));
     WirePage();
 }
Example #6
0
 public MainPageController
 (
     IMainPage mainPage,
     IMainPageViewModel mainPageViewModel,
     ILrpNavigation navigation,
     ICollectionMvcBuilder <Uom> uomMvcBuilder
 )
 {
     _mainPage          = mainPage ?? throw new ArgumentNullException(nameof(mainPage));
     _mainPageViewModel = mainPageViewModel ?? throw new ArgumentNullException(nameof(mainPageViewModel));
     _navigation        = navigation ?? throw new ArgumentNullException(nameof(navigation));
     _uomMvcBuilder     = uomMvcBuilder ?? throw new ArgumentNullException(nameof(uomMvcBuilder));
     WireController();
 }
Example #7
0
        public async Task BuildAsync(ILrpNavigation navigation, string pageTitle)
        {
            var viewModel = _createViewModel(pageTitle);
            var page      = _createPage();

            page.InitializePage();
            page.BindingContext = viewModel;
            _createPageController
            (
                navigation,
                viewModel,
                page
            );
            await navigation.PushAsync(page as ContentPage);
        }
Example #8
0
 public LoginPageController
 (
     IMainPage mainPage,
     IJwtTokenManager tokenManager,
     Func <ILoginPage> createLoginPage,
     ILrpNavigation navigation
 )
 {
     _navigation = navigation ?? throw new ArgumentNullException(nameof(navigation));
     if (mainPage == null)
     {
         throw new ArgumentNullException(nameof(mainPage));
     }
     mainPage.OnAppearingCalledEvent += MainPageOnAppearingCalled;
     _tokenManager    = tokenManager ?? throw new ArgumentNullException(nameof(tokenManager));
     _createLoginPage = createLoginPage ?? throw new ArgumentNullException(nameof(createLoginPage));
 }