コード例 #1
0
ファイル: ShellUriHandlerTests.cs プロジェクト: lhx11187/maui
        public async Task ShellSectionWithRelativeEditUpOneLevelMultiple()
        {
            var shell = new Shell();
            var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1", shellSectionRoute: "section1");

            Routing.RegisterRoute("section1/edit", typeof(ContentPage));
            Routing.RegisterRoute("section1/add", typeof(ContentPage));

            shell.Items.Add(item1);

            var request = ShellUriHandler.GetNavigationRequest(shell, CreateUri("//rootlevelcontent1/add/edit"));

            Assert.AreEqual(2, request.Request.GlobalRoutes.Count);
            Assert.AreEqual("section1/add", request.Request.GlobalRoutes.First());
            Assert.AreEqual("section1/edit", request.Request.GlobalRoutes.Skip(1).First());
        }
コード例 #2
0
        public async Task ShellSectionWithGlobalRouteRelative()
        {
            var shell = new Shell();
            var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1", shellSectionRoute: "section1");

            Routing.RegisterRoute("edit", typeof(ContentPage));

            shell.Items.Add(item1);

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

            var request = ShellUriHandler.GetNavigationRequest(shell, CreateUri("edit"));

            Assert.AreEqual(1, request.Request.GlobalRoutes.Count);
            Assert.AreEqual("edit", request.Request.GlobalRoutes.First());
        }
コード例 #3
0
ファイル: ShellUriHandlerTests.cs プロジェクト: sung-su/maui
        public async Task ShellItemAndContentOnly()
        {
            var shell = new Shell();
            var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent", shellItemRoute: "item1");
            var item2 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent", shellItemRoute: "item2");

            shell.Items.Add(item1);
            shell.Items.Add(item2);


            var builders = ShellUriHandler.GenerateRoutePaths(shell, CreateUri("//item1/rootlevelcontent")).Select(x => x.PathNoImplicit).ToArray();

            Assert.AreEqual(1, builders.Length);
            Assert.IsTrue(builders.Contains("//item1/rootlevelcontent"));

            builders = ShellUriHandler.GenerateRoutePaths(shell, CreateUri("//item2/rootlevelcontent")).Select(x => x.PathNoImplicit).ToArray();
            Assert.AreEqual(1, builders.Length);
            Assert.IsTrue(builders.Contains("//item2/rootlevelcontent"));
        }
コード例 #4
0
ファイル: ShellUriHandlerTests.cs プロジェクト: sung-su/maui
        public async Task ShellContentOnly()
        {
            var shell = new Shell();
            var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1");
            var item2 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent2");

            shell.Items.Add(item1);
            shell.Items.Add(item2);


            var builders = ShellUriHandler.GenerateRoutePaths(shell, CreateUri("//rootlevelcontent1"));

            Assert.AreEqual(1, builders.Count);
            Assert.AreEqual("//rootlevelcontent1", builders.First().PathNoImplicit);

            builders = ShellUriHandler.GenerateRoutePaths(shell, CreateUri("//rootlevelcontent2"));
            Assert.AreEqual(1, builders.Count);
            Assert.AreEqual("//rootlevelcontent2", builders.First().PathNoImplicit);
        }
コード例 #5
0
        public async Task ConvertToStandardFormat()
        {
            var shell = new Shell()
            {
                RouteScheme = "app", Route = "shellroute", RouteHost = "host"
            };

            Uri[] TestUris = new Uri[] {
                CreateUri("path"),
                CreateUri("//path"),
                CreateUri("/path"),
                CreateUri("host/path"),
                CreateUri("//host/path"),
                CreateUri("/host/path"),
                CreateUri("shellroute/path"),
                CreateUri("//shellroute/path"),
                CreateUri("/shellroute/path"),
                CreateUri("host/shellroute/path"),
                CreateUri("//host/shellroute/path"),
                CreateUri("/host/shellroute/path"),
                CreateUri("app://path"),
                CreateUri("app:/path"),
                CreateUri("app://host/path"),
                CreateUri("app:/host/path"),
                CreateUri("app://shellroute/path"),
                CreateUri("app:/shellroute/path"),
                CreateUri("app://host/shellroute/path"),
                CreateUri("app:/host/shellroute/path"),
                CreateUri("app:/host/shellroute\\path")
            };


            foreach (var uri in TestUris)
            {
                Assert.AreEqual(new Uri("app://host/shellroute/path"), ShellUriHandler.ConvertToStandardFormat(shell, uri));

                if (!uri.IsAbsoluteUri)
                {
                    var reverse = new Uri(uri.OriginalString.Replace("/", "\\"), UriKind.Relative);
                    Assert.AreEqual(new Uri("app://host/shellroute/path"), ShellUriHandler.ConvertToStandardFormat(shell, reverse));
                }
            }
        }
コード例 #6
0
ファイル: ShellUriHandlerTests.cs プロジェクト: sung-su/maui
        public async Task ConvertToStandardFormat()
        {
            var shell = new Shell();

            Uri[] TestUris = new Uri[] {
                CreateUri("path"),
                CreateUri("//path"),
                CreateUri("/path"),
                CreateUri("shell/path"),
                CreateUri("//shell/path"),
                CreateUri("/shell/path"),
                CreateUri("IMPL_shell/path"),
                CreateUri("//IMPL_shell/path"),
                CreateUri("/IMPL_shell/path"),
                CreateUri("shell/IMPL_shell/path"),
                CreateUri("//shell/IMPL_shell/path"),
                CreateUri("/shell/IMPL_shell/path"),
                CreateUri("app://path"),
                CreateUri("app:/path"),
                CreateUri("app://shell/path"),
                CreateUri("app:/shell/path"),
                CreateUri("app://shell/IMPL_shell/path"),
                CreateUri("app:/shell/IMPL_shell/path"),
                CreateUri("app:/shell/IMPL_shell\\path")
            };


            foreach (var uri in TestUris)
            {
                Assert.AreEqual(new Uri("app://shell/IMPL_shell/path"), ShellUriHandler.ConvertToStandardFormat(shell, uri), $"{uri}");

                if (!uri.IsAbsoluteUri)
                {
                    var reverse = new Uri(uri.OriginalString.Replace('/', '\\'), UriKind.Relative);
                    Assert.AreEqual(new Uri("app://shell/IMPL_shell/path"), ShellUriHandler.ConvertToStandardFormat(shell, reverse));
                }
            }
        }
コード例 #7
0
ファイル: ShellTestBase.cs プロジェクト: wmhang/Xamarin.Forms
 protected Uri CreateUri(string uri) => ShellUriHandler.CreateUri(uri);