public async Task Back()
        {
            var mocks = new CollectionPageControllerMocks <Uom>();
            var page  = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            mocks.LrpNavigation.Setup(v => v.PopAsync()).ReturnsAsync(page);
            BuildController(mocks, page);

            await page.OnBackButtonPressedAsync();
        }
        public async Task OnAppearingNotEditing()
        {
            var mocks = new CollectionPageControllerMocks <Uom>();

            mocks.CollectionPageViewModel.Setup(v => v.SearchAsync(string.Empty)).Returns(Task.CompletedTask);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            BuildController(mocks, page);

            await page.OnAppearingAsync();
        }
 public CollectionPageController <TItem> BuildController <TItem>(CollectionPageControllerMocks <TItem> mocks, CollectionPage <TItem> page)
     where TItem : class, IEntity
 {
     return(new CollectionPageController <TItem>
            (
                mocks.LrpNavigation.Object,
                mocks.CollectionPageViewModel.Object,
                page,
                mocks.ItemMvcBuilder.Object
            ));
 }
        public async Task PageBack()
        {
            var uomToDelete = new Uom();
            var mocks       = new CollectionPageControllerMocks <Uom>();

            mocks.CollectionPageViewModel.Setup(v => v.PageBackAsync()).Returns(Task.CompletedTask);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            BuildController(mocks, page);

            await page.PageBackClickedAsync();
        }
        public async Task EditWorkflow()
        {
            var uom   = new Uom();
            var mocks = new CollectionPageControllerMocks <Uom>();

            mocks.CollectionPageViewModel.Setup(v => v.RefreshAsync()).Returns(Task.CompletedTask);
            SetupForAddEditWorkflow(mocks, uom);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            BuildController(mocks, page);

            await page.OnItemSelectedAsync(uom);
        }
 public void SetupForAddEditWorkflow <TItem>(CollectionPageControllerMocks <TItem> mocks, TItem item = null)
     where TItem : class, IEntity
 {
     if (item == null)
     {
         mocks.ItemMvcBuilder.Setup(i => i.BuildAddAsync(mocks.LrpNavigation.Object))
         .Returns(Task.CompletedTask);
     }
     else
     {
         mocks.ItemMvcBuilder.Setup(i => i.BuildEditAsync(mocks.LrpNavigation.Object, item))
         .Returns(Task.CompletedTask);
     }
 }
        public async Task DeleteItem()
        {
            var uomToDelete = new Uom();
            var mocks       = new CollectionPageControllerMocks <Uom>();

            mocks.CollectionPageViewModel.Setup(v => v.DeleteAsync(uomToDelete)).Returns(Task.CompletedTask);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            BuildController(mocks, page);

            await page.DeleteButtonClickedAsync();

            await page.OnItemSelectedAsync(uomToDelete);
        }
        public async Task OnAppearingIsEditing()
        {
            var mocks = new CollectionPageControllerMocks <Uom>();

            mocks.CollectionPageViewModel.Setup(v => v.RefreshAsync()).Returns(Task.CompletedTask);
            SetupForAddEditWorkflow(mocks);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            BuildController(mocks, page);

            await page.AddButtonClickedAsync();

            await page.OnAppearingAsync();
        }
        public async Task SearchRequested()
        {
            var uomToDelete = new Uom();
            var mocks       = new CollectionPageControllerMocks <Uom>();

            MockForms.Init(); // for the page SearchBar
            mocks.CollectionPageViewModel.Setup(v => v.SearchAsync("j")).Returns(Task.CompletedTask);
            var page = new CollectionPage <Uom>(mocks.CreateViewCell.Object);

            page.InitializePage();
            BuildController(mocks, page);

            page.SearchBar.Text = "j";
            await page.SearchRequestedAsync();
        }