コード例 #1
0
        public async Task GlobalRoutesRegisteredHierarchicallyWithDoublePop()
        {
            Routing.RegisterRoute("monkeys/monkeyDetails", typeof(TestPage1));
            Routing.RegisterRoute("monkeyDetails/monkeygenome", typeof(TestPage2));
            var shell = new TestShell(
                CreateShellItem(shellContentRoute: "monkeys", shellItemRoute: "animals2"),
                CreateShellItem(shellContentRoute: "monkeys", shellItemRoute: "animals")
                );

            await shell.GoToAsync("//animals/monkeys/monkeyDetails?id=123");

            await shell.GoToAsync("monkeygenome");

            await shell.GoToAsync("../..");

            Assert.AreEqual("//animals/monkeys", shell.CurrentState.Location.ToString());
        }
コード例 #2
0
        public async Task NavigatedFiresAfterContentIsCreatedWhenUsingTemplate()
        {
            Shell shell = new TestShell();

            FlyoutItem   flyoutItem = new FlyoutItem();
            Tab          tab        = new Tab();
            ContentPage  page       = null;
            ShellContent content    = new ShellContent()
            {
                Route           = "destination",
                ContentTemplate = new DataTemplate(() =>
                {
                    page = new ContentPage();
                    return(page);
                })
            };

            flyoutItem.Items.Add(tab);
            tab.Items.Add(content);

            shell.Items.Add(CreateShellItem());
            shell.Items.Add(flyoutItem);

            Assert.AreNotEqual(shell.CurrentItem.CurrentItem.CurrentItem, content);
            Assert.IsNull(page);

            bool navigated = false;

            shell.Navigated += (_, __) =>
            {
                Assert.IsNotNull(page);
                Assert.IsNotNull((content as IShellContentController).Page);
                navigated = true;
            };

            await shell.GoToAsync("///destination");

            // content hasn't been created yet
            Assert.IsFalse(navigated);

            var createPage = (content as IShellContentController).GetOrCreateContent();

            Assert.AreEqual(createPage, page);
            Assert.IsTrue(navigated);
        }
コード例 #3
0
        public void TestAttachingWithAlreadyCanceledToken()
        {
            var cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.Cancel();
            var processCommand = TestShell.Run(SampleCommand, new[] { "sleep", "10000" });
            var processId      = processCommand.ProcessId;

            Command.TryAttachToProcess(
                processId,
                options => options.CancellationToken(cancellationTokenSource.Token).DisposeOnExit(false),
                out var attachedCommand)
            .ShouldEqual(true, "attaching failed");
            using (attachedCommand)
            {
                attachedCommand !.Process.WaitForExit(1000).ShouldEqual(true, "The process wasn't killed.");
            }
        }
コード例 #4
0
ファイル: ShellModalTests.cs プロジェクト: sung-su/maui
        public async Task GetCurrentPageInModalNavigation()
        {
            Shell shell = new TestShell();

            shell.Items.Add(CreateShellItem(shellItemRoute: "NewRoute", shellSectionRoute: "Section", shellContentRoute: "Content"));

            Page page = null;

            shell.Navigated += (_, __) =>
            {
                page = shell.CurrentPage;
            };

            await shell.GoToAsync("ModalTestPage");

            Assert.IsNotNull(page);
            Assert.AreEqual(page.GetType(), typeof(ModalTestPage));
        }
コード例 #5
0
ファイル: ShellLifeCycleTests.cs プロジェクト: ultracpy/maui
        public async Task OnNavigatedFiresWhenPopToRoot()
        {
            Routing.RegisterRoute("AlarmPage", typeof(LifeCyclePage));
            Routing.RegisterRoute("SoundsPage", typeof(LifeCyclePage));
            TestShell shell = new TestShell();

            var item = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);

            shell.Items.Add(item);

            await shell.GoToAsync("AlarmPage/SoundsPage");

            shell.Reset();

            await shell.Navigation.PopToRootAsync();

            shell.TestCount(1);
        }
コード例 #6
0
        public void FlyoutItemVisibleWorksForMenuItemsAddedAsShellItem()
        {
            var shell = new TestShell();
            var item  = new MenuShellItem(CreateNonVisibleMenuItem());

            shell.Items.Add(item);

            var itemsAreEquals = item.Equals(shell.Items[0]);

            Assert.IsTrue(itemsAreEquals);

            IShellController shellController = (IShellController)shell;
            var groups = shellController.GenerateFlyoutGrouping();

            var r = groups.SelectMany(x => x.OfType <IMenuItemController>());

            Assert.AreEqual(r.Count(), 0);
        }
コード例 #7
0
        public async Task InsertPageFromNavigationSetsCorrectNavigationSource()
        {
            Routing.RegisterRoute("pagemiddle", typeof(ContentPage));
            Routing.RegisterRoute("page", typeof(ContentPage));
            var shell = new TestShell(
                CreateShellItem(shellItemRoute: "item")
                );

            await shell.GoToAsync("//item/page");

            ContentPage contentPage = new ContentPage();

            Routing.SetRoute(contentPage, "pagemiddle");
            shell.Navigation.InsertPageBefore(contentPage, shell.Navigation.NavigationStack.Last());

            shell.TestNavigationArgs(ShellNavigationSource.Insert,
                                     "//item/page", "//item/pagemiddle/page");
        }
コード例 #8
0
        public void ToolBarShouldBeVisibleWithEmptyTitleAndFlyoutBehaviorSetToFlyout()
        {
            TestShell testShell = new TestShell()
            {
                CurrentItem = new FlyoutItem()
                {
                    CurrentItem = new ContentPage()
                }
            };

            _ = new Window()
            {
                Page = testShell
            };
            var toolbar = testShell.Toolbar;

            Assert.IsTrue(toolbar.IsVisible);
        }
コード例 #9
0
ファイル: ShellModalTests.cs プロジェクト: sung-su/maui
        public async Task CanCancelPushModalAsync()
        {
            TestShell shell = new TestShell();

            shell.Items.Add(CreateShellItem());
            shell.Navigating += async(_, args) =>
            {
                var deferral = args.GetDeferral();
                await Task.Delay(10);

                args.Cancel();
                deferral.Complete();
            };

            await shell.CurrentPage.Navigation.PushModalAsync(new ContentPage());

            Assert.AreEqual(0, shell.Navigation.ModalStack.Count);
        }
コード例 #10
0
        public void FlyoutItemsBasicSyncTest()
        {
            var shell = new TestShell();

            shell.Items.Add(CreateShellItem <FlyoutItem>());
            shell.Items.Add(CreateShellItem <FlyoutItem>());
            shell.Items.Add(CreateShellItem <FlyoutItem>());
            shell.Items.Add(CreateShellItem <FlyoutItem>());
            shell.Items[3].IsVisible = false;

            var flyoutItems = shell.GenerateTestFlyoutItems();

            Assert.AreEqual(shell.Items[0], flyoutItems[0][0]);
            Assert.AreEqual(shell.Items[1], flyoutItems[0][1]);
            Assert.AreEqual(shell.Items[2], flyoutItems[0][2]);
            Assert.AreEqual(3, flyoutItems[0].Count);
            Assert.AreEqual(1, flyoutItems.Count);
        }
コード例 #11
0
        public async Task InsertTwoPagesAtSeparatePoints()
        {
            Routing.RegisterRoute("pagefirstmiddle", typeof(ContentPage));
            Routing.RegisterRoute("pagesecondmiddle", typeof(ContentPage));
            Routing.RegisterRoute("last", typeof(ContentPage));
            Routing.RegisterRoute("middle", typeof(ContentPage));

            var shell = new TestShell(
                CreateShellItem(shellItemRoute: "item")
                );

            await shell.GoToAsync("//item/middle/last");

            await shell.GoToAsync("//item/pagefirstmiddle/middle/pagesecondmiddle/last");

            Assert.That(shell.CurrentState.Location.ToString(),
                        Is.EqualTo("//item/pagefirstmiddle/middle/pagesecondmiddle/last"));
        }
コード例 #12
0
        public async Task NavigateToDefaultShellContent()
        {
            TestShell testShell = new TestShell(CreateShellItem <FlyoutItem>());
            var       page      = new ContentPage();

            var contentRoute = testShell.CurrentItem.CurrentItem.CurrentItem.Route;
            var pageRoute    = Routing.GetRoute(page);

            await testShell.Navigation.PushAsync(new ContentPage());

            await testShell.Navigation.PushAsync(page);

            await testShell.GoToAsync($"//{contentRoute}/{pageRoute}");


            Assert.That(testShell.CurrentState.Location.ToString(),
                        Is.EqualTo($"//{contentRoute}/{pageRoute}"));
        }
コード例 #13
0
        public async Task ShellPartWithModalPush()
        {
            Shell shell = new TestShell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);
            ShellLifeCycleState lifeCycleState = new ShellLifeCycleState(item);

            shell.Items.Add(item);

            lifeCycleState.AllTrue();

            ContentPage page = new ContentPage();
            await shell.Navigation.PushModalAsync(page);

            lifeCycleState.AllFalse();
            await shell.Navigation.PopModalAsync();

            lifeCycleState.AllTrue();
        }
コード例 #14
0
 public void TestCancellationCanceledPartway()
 {
     using (var cancellationTokenSource = new CancellationTokenSource())
     {
         var results = new SyncCollection();
         var command = TestShell.Run(SampleCommand, new object[] { "echo", "--per-char" }, o => o.CancellationToken(cancellationTokenSource.Token)) > results;
         command.StandardInput.WriteLine("hello");
         var timeout = Task.Delay(TimeSpan.FromSeconds(10));
         while (results.Count == 0 && !timeout.IsCompleted)
         {
         }
         results.Count.ShouldEqual(1);
         cancellationTokenSource.Cancel();
         var aggregateException = Assert.Throws <AggregateException>(() => command.Task.Wait(1000));
         Assert.IsInstanceOf <TaskCanceledException>(aggregateException.GetBaseException());
         CollectionAssert.AreEqual(results, new[] { "hello" });
     }
 }
コード例 #15
0
        public void TestStopBufferingAndDiscard()
        {
            var command = TestShell.Run(SampleCommand, "pipe");

            command.StandardOutput.StopBuffering();
            var line         = new string('a', 100);
            var state        = 0;
            var linesWritten = 0;

            while (state < 2)
            {
                Log.WriteLine("Write to unbuffered command");
                var task = command.StandardInput.WriteLineAsync(line);
                if (!task.Wait(TimeSpan.FromSeconds(1)))
                {
                    if (state == 0)
                    {
                        Log.WriteLine("Buffer full: read");
                        // for whatever reason, on Unix I need to read a few lines to get things flowing again
                        var linesToRead = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 1 : Math.Max((int)(.1 * linesWritten), 1);
                        for (var i = 0; i < linesToRead; ++i)
                        {
                            var outLine = command.StandardOutput.ReadLine();
                            outLine.ShouldEqual(line);
                        }
                        // after this, we may need to write more content than we read to re-block since the reader
                        // buffers internally
                    }
                    else
                    {
                        Log.WriteLine("Buffer full: discard content");
                        command.StandardOutput.Discard();
                    }

                    task.Wait(TimeSpan.FromSeconds(3)).ShouldEqual(true, $"can finish after read (state={state}, linesWritten={linesWritten})");
                    if (state == 1)
                    {
                        command.StandardInput.Dispose();
                    }
                    state++;
                }
                ++linesWritten;
            }
        }
コード例 #16
0
        public async Task DeferPopNavigation(string testCase)
        {
            TestShell shell = new TestShell()
            {
                Items = { CreateShellItem <FlyoutItem>() }
            };

            await shell.Navigation.PushAsync(new ContentPage());

            await shell.Navigation.PushAsync(new ContentPage());

            ShellNavigatingDeferral _token = null;

            shell.Navigating += async(_, args) =>
            {
                _token = args.GetDeferral();
                await Task.Delay(500);

                Assert.AreEqual(3, shell.Navigation.NavigationStack.Count);
                _token.Complete();
            };

            var source = new TaskCompletionSource <object>();

            shell.Navigated += (_, args) =>
            {
                source.SetResult(true);
            };

            if (testCase == "Pop")
            {
                await shell.Navigation.PopAsync();

                await source.Task;
                Assert.AreEqual(2, shell.Navigation.NavigationStack.Count);
            }
            else
            {
                await shell.Navigation.PopToRootAsync();

                await source.Task;
                Assert.AreEqual(1, shell.Navigation.NavigationStack.Count);
            }
        }
コード例 #17
0
        public async Task GlobalRoutesRegisteredHierarchicallyNavigateCorrectlyWithAdditionalItems()
        {
            Routing.RegisterRoute("monkeys/monkeyDetails", typeof(TestPage1));
            Routing.RegisterRoute("monkeyDetails/monkeygenome", typeof(TestPage2));
            var shell = new TestShell(
                CreateShellItem(shellContentRoute: "cats", shellSectionRoute: "domestic", shellItemRoute: "animals")
                );

            shell.Items[0].Items.Add(CreateShellContent(shellContentRoute: "monkeys"));
            shell.Items[0].Items.Add(CreateShellContent(shellContentRoute: "elephants"));
            shell.Items[0].Items.Add(CreateShellContent(shellContentRoute: "bears"));
            shell.Items[0].Items[0].Items.Add(CreateShellContent(shellContentRoute: "dogs"));
            shell.Items.Add(CreateShellContent(shellContentRoute: "about"));
            await shell.GoToAsync("//animals/monkeys/monkeyDetails?id=123");

            await shell.GoToAsync("monkeygenome");

            Assert.AreEqual("//animals/monkeys/monkeyDetails/monkeygenome", shell.CurrentState.Location.ToString());
        }
コード例 #18
0
        public async Task PoppingSetsCorrectNavigationSource()
        {
            var shell = new TestShell(CreateShellItem(shellContentRoute: "item1"));

            shell.RegisterPage("page1");
            shell.RegisterPage("page2");

            await shell.GoToAsync("page1");

            await shell.GoToAsync("page2");

            await shell.Navigation.PopAsync();

            shell.TestNavigatingArgs(ShellNavigationSource.Pop,
                                     "//item1/page1/page2", $"..");

            shell.TestNavigatedArgs(ShellNavigationSource.Pop,
                                    "//item1/page1/page2", $"//item1/page1");
        }
コード例 #19
0
        public async Task NavigationTaskCompletesAfterDeferralHasFinished(string testCase)
        {
            Routing.RegisterRoute(nameof(NavigationTaskCompletesAfterDeferralHasFinished), typeof(ContentPage));
            var shell = new TestShell()
            {
                Items = { CreateShellItem <FlyoutItem>() }
            };

            ShellNavigatingDeferral _token = null;

            shell.Navigating += async(_, args) =>
            {
                _token = args.GetDeferral();
                await Task.Delay(500);

                _token.Complete();
            };

            switch (testCase)
            {
            case "PopToRoot":
                await shell.Navigation.PopToRootAsync();

                break;

            case "Pop":
                await shell.Navigation.PopAsync();

                break;

            case "GoToAsync":
                await shell.GoToAsync(nameof(NavigationTaskCompletesAfterDeferralHasFinished));

                break;

            case "Push":
                await shell.Navigation.PushAsync(new ContentPage());

                break;
            }

            Assert.IsTrue(_token.IsCompleted);
        }
コード例 #20
0
ファイル: ShellToolbarTests.cs プロジェクト: dimonovdd/maui
        public async Task ShellToolbarUpdatesFromPropertyChanged()
        {
            var       page      = new ContentPage();
            TestShell testShell = new TestShell(new ContentPage());

            Shell.SetBackButtonBehavior(page, new BackButtonBehavior());
            await testShell.Navigation.PushAsync(page);

            Assert.IsTrue(testShell.Toolbar.IsVisible);
            var backButtonBehavior = new BackButtonBehavior()
            {
                IsVisible = true,
            };

            Shell.SetBackButtonBehavior(page, backButtonBehavior);
            Assert.IsTrue(testShell.Toolbar.BackButtonVisible);
            backButtonBehavior.IsVisible = false;
            Assert.IsFalse(testShell.Toolbar.BackButtonVisible);
        }
コード例 #21
0
ファイル: ShellModalTests.cs プロジェクト: sung-su/maui
        public async Task AppearingAndDisappearingFiresOnShellWithModal()
        {
            Shell shell = new TestShell();

            shell.NavigationProxy.Inner = new NavigationProxy();
            var lifeCyclePage = new ShellLifeCycleTests.LifeCyclePage();

            shell.Items.Add(CreateShellItem(lifeCyclePage, shellItemRoute: "item", shellSectionRoute: "section", shellContentRoute: "content"));

            var shellLifeCycleState = new ShellLifeCycleTests.ShellLifeCycleState(shell);
            await shell.GoToAsync("ModalTestPage");

            await shell.Navigation.ModalStack[0].Navigation.PopModalAsync();

            shellLifeCycleState.AllTrue();
            await shell.GoToAsync("ModalTestPage");

            shellLifeCycleState.AllFalse();
        }
コード例 #22
0
        public void TestGetOutputAndErrorLines()
        {
            // simple echo case
            var command = TestShell.Run(SampleCommand, "echo") < new[] { "a", "b", "c" };

            string.Join(", ", command.GetOutputAndErrorLines().ToList()).ShouldEqual("a, b, c");

            // failure case: stderr not redirected
            command = TestShell.Run(SampleCommand, new[] { "echo" }, options: o => o.StartInfo(s => s.RedirectStandardError = false)) < new[] { "a" };
            Assert.Throws <InvalidOperationException>(() => command.GetOutputAndErrorLines());

            // fuzz case
            var lines = Enumerable.Range(0, 5000).Select(_ => Guid.NewGuid().ToString()).ToArray();

            command = TestShell.Run(SampleCommand, "echoLinesToBothStreams") < lines;
            var outputLines = command.GetOutputAndErrorLines().ToList();

            CollectionAssert.AreEquivalent(lines, outputLines);
        }
コード例 #23
0
ファイル: ShellToolbarTests.cs プロジェクト: dimonovdd/maui
        public async Task BackButtonDisabledWhenCommandDisabled()
        {
            var       page      = new ContentPage();
            TestShell testShell = new TestShell(new ContentPage());
            await testShell.Navigation.PushAsync(page);

            var backButtonBehavior = new BackButtonBehavior();

            Shell.SetBackButtonBehavior(page, backButtonBehavior);
            Assert.IsTrue(testShell.Toolbar.BackButtonEnabled);

            bool canExecute = false;

            backButtonBehavior.Command = new Command(() => { }, () => canExecute);
            Assert.IsFalse(testShell.Toolbar.BackButtonEnabled);
            canExecute = true;
            (backButtonBehavior.Command as Command).ChangeCanExecute();
            Assert.IsTrue(testShell.Toolbar.BackButtonEnabled);
        }
コード例 #24
0
        public async Task CancelNavigationOccurringOutsideGotoAsync()
        {
            var       flyoutItem = CreateShellItem <FlyoutItem>();
            TestShell shell      = new TestShell()
            {
                Items = { flyoutItem }
            };

            var navigatingToShellContent = CreateShellContent();

            shell.Items[0].Items[0].Items.Add(navigatingToShellContent);

            bool executed = false;
            TaskCompletionSource <object> taskCompletionSource = new TaskCompletionSource <object>();

            ShellContent contentActiveBeforeCompletingDeferral = null;

            shell.Navigating += async(_, args) =>
            {
                var deferral = args.GetDeferral();
                await Task.Delay(100);

                contentActiveBeforeCompletingDeferral = flyoutItem.Items[0].Items[0];
                executed = true;
                deferral.Complete();
            };

            shell.Navigated += (_, args) =>
            {
                taskCompletionSource.SetResult(true);
            };

            shell.Controller.ProposeNavigation(
                ShellNavigationSource.ShellContentChanged, flyoutItem, flyoutItem.Items[0], navigatingToShellContent, flyoutItem.Items[0].Stack, true);

            await taskCompletionSource.Task;

            Assert.IsTrue(executed);
            Assert.AreNotEqual(contentActiveBeforeCompletingDeferral, navigatingToShellContent);
            Assert.AreEqual(flyoutItem.Items[0].Items[0], contentActiveBeforeCompletingDeferral, "Navigation to new Content was not deferred");
            Assert.AreEqual(flyoutItem.Items[0].CurrentItem, navigatingToShellContent, "Navigation after completing the deferral failed");
        }
コード例 #25
0
        public async Task GlobalRoutesRegisteredHierarchicallyNavigateCorrectly()
        {
            Routing.RegisterRoute("first", typeof(TestPage1));
            Routing.RegisterRoute("first/second", typeof(TestPage2));
            Routing.RegisterRoute("first/second/third", typeof(TestPage3));
            var shell = new TestShell(
                CreateShellItem(shellContentRoute: "MainPage")
                );

            await shell.GoToAsync("//MainPage/first/second");

            Assert.AreEqual(typeof(TestPage1), shell.Navigation.NavigationStack[1].GetType());
            Assert.AreEqual(typeof(TestPage2), shell.Navigation.NavigationStack[2].GetType());

            await shell.GoToAsync("//MainPage/first/second/third");

            Assert.AreEqual(typeof(TestPage1), shell.Navigation.NavigationStack[1].GetType());
            Assert.AreEqual(typeof(TestPage2), shell.Navigation.NavigationStack[2].GetType());
            Assert.AreEqual(typeof(TestPage3), shell.Navigation.NavigationStack[3].GetType());
        }
コード例 #26
0
        public async Task PagePush()
        {
            Shell shell = new TestShell();
            var   item  = CreateShellItem(shellContentRoute: ContentRoute, shellSectionRoute: SectionRoute, shellItemRoute: ItemRoute);

            shell.Items.Add(item);

            ContentPage page      = new ContentPage();
            bool        appearing = false;

            page.Appearing    += (_, __) => appearing = true;
            page.Disappearing += (_, __) => appearing = false;

            await shell.Navigation.PushAsync(page);

            Assert.IsTrue(appearing);
            await shell.Navigation.PopAsync();

            Assert.IsFalse(appearing);
        }
コード例 #27
0
        public void TestStandardErrorCannotBeAccessedAfterRedirectingIt()
        {
            var output    = new List <string>();
            var command   = TestShell.Run(SampleCommand, "argecho", "a");
            var ioCommand = command.RedirectStandardErrorTo(output);

            var errorMessage = Assert.Throws <InvalidOperationException>(() => ioCommand.StandardError.GetHashCode()).Message;

            errorMessage.ShouldEqual("StandardError is unavailable because it is already being piped to System.Collections.Generic.List`1[System.String]");

            Assert.DoesNotThrow(() => command.StandardError.GetHashCode());

            Assert.Throws <InvalidOperationException>(() => ioCommand.Result.StandardError.GetHashCode())
            .Message
            .ShouldEqual(errorMessage);
            Assert.Throws <ObjectDisposedException>(() => command.Result.StandardError.GetHashCode());

            Assert.IsEmpty(output);
            ioCommand.Result.StandardOutput.ShouldEqual(command.Result.StandardOutput).ShouldEqual($"a{Environment.NewLine}");
        }
コード例 #28
0
        public async Task HierarchicalNavigationWithBackNavigation()
        {
            Routing.RegisterRoute("page1/page2", typeof(ShellTestPage));
            Routing.RegisterRoute("page1/page2/page3", typeof(TestPage1));
            var shell = new TestShell(
                CreateShellItem(shellSectionRoute: "page1")
                );

            await shell.GoToAsync($"page1/page2");

            await shell.GoToAsync($"page1/page2/page3");

            Assert.IsTrue(shell.CurrentPage is TestPage1);
            await shell.GoToAsync($"..");

            Assert.IsTrue(shell.CurrentPage is ShellTestPage);
            await shell.GoToAsync($"..");

            Assert.IsTrue(shell.CurrentPage is ContentPage);
        }
コード例 #29
0
        public void FlyoutItemsGroupTestWithRemove()
        {
            var shell = new TestShell();

            shell.Items.Add(CreateShellItem <FlyoutItem>());
            shell.Items.Add(CreateShellItem <FlyoutItem>());
            var sec1 = shell.Items[0].Items[0];
            var sec2 = CreateShellSection <Tab>();
            var sec3 = CreateShellSection <Tab>();

            shell.Items[0].FlyoutDisplayOptions = FlyoutDisplayOptions.AsMultipleItems;
            shell.Items[0].Items.Add(sec2);
            shell.Items[0].Items.Add(sec3);
            shell.Items.RemoveAt(0);

            var flyoutItems = shell.GenerateTestFlyoutItems();

            Assert.AreEqual(shell.Items[0], flyoutItems[0][0]);
            Assert.AreEqual(1, flyoutItems.Count);
        }
コード例 #30
0
        public async Task ImmediatelyCompleteDeferral()
        {
            TestShell shell = new TestShell()
            {
                Items = { CreateShellItem <FlyoutItem>() }
            };

            bool executed = false;

            shell.Navigating += (_, args) =>
            {
                var deferral = args.GetDeferral();
                executed = true;
                deferral.Complete();
            };

            await shell.Navigation.PushAsync(new ContentPage());

            Assert.IsTrue(executed);
            Assert.AreEqual(2, shell.Navigation.NavigationStack.Count);
        }