Exemplo n.º 1
0
        public void TwoRoutesOnTheSameFolderHaveSimilarNames()
        {
            //Arrange
            var portalInfo = new ArrayList {
                new PortalInfo {
                    PortalID = 0
                }
            };

            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);
            var mockPac = new Mock <IPortalAliasController>();

            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo {
                                                                                  HTTPAlias = "www.foo.com"
                                                                              } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var routeCollection = new RouteCollection();
            var srm             = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });
            srm.MapRoute("folder", "alt/url", new[] { "foo" });

            //Assert
            var route = (Route)routeCollection[0];

            Assert.AreEqual("folder-route0-instance0", route.DataTokens["Name"]);
            route = (Route)routeCollection[1];
            Assert.AreEqual("folder-route1-instance0", route.DataTokens["Name"]);
        }
Exemplo n.º 2
0
        public void SimpleDomainMakes1Route()
        {
            //Arrange
            var portalInfo = new ArrayList {
                new PortalInfo {
                    PortalID = 0
                }
            };

            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);
            var mockPac = new Mock <IPortalAliasController>();

            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo {
                                                                                  HTTPAlias = "www.foo.com"
                                                                              } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var routeCollection = new RouteCollection();
            var srm             = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });

            //Assert
            Assert.AreEqual(1, routeCollection.Count);
        }
Exemplo n.º 3
0
        public void VirtualDirOnlyMakesRouteWithNoWildcardPrefix()
        {
            //Arrange
            var portalInfo = new ArrayList {
                new PortalInfo {
                    PortalID = 0
                }
            };

            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);

            var mockPac = new Mock <IPortalAliasController>();

            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo {
                                                                                  HTTPAlias = "www.foo.com/vdir"
                                                                              } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var mockGlobals = new Mock <IGlobals>();

            mockGlobals.Setup(x => x.ApplicationPath).Returns("/vdir");
            TestableGlobals.SetTestableInstance(mockGlobals.Object);

            var routeCollection = new RouteCollection();
            var srm             = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });

            //Assert
            Assert.AreEqual(1, routeCollection.Count);
            var route = (Route)routeCollection[0];

            StringAssert.DoesNotStartWith("{", route.Url);
        }
Exemplo n.º 4
0
        public void UrlCanStartWithSlash()
        {
            //Arrange
            _mockPortalController.Setup(x => x.GetPortals()).Returns(new ArrayList());

            //Act
            var srm = new ServicesRoutingManager(new RouteCollection());

            //Assert
            Assert.DoesNotThrow(() => srm.MapRoute("name", "/url", null, new[] { "foo" }));
        }
Exemplo n.º 5
0
        public void VirtualDirWithChild()
        {
            //Arrange
            var portalInfo = new ArrayList {
                new PortalInfo {
                    PortalID = 0
                }
            };

            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);

            var mockPac = new Mock <IPortalAliasController>();

            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo {
                                                                                  HTTPAlias = "www.foo.com/vdir"
                                                                              }, new PortalAliasInfo {
                                                                                  HTTPAlias = "www.foo.com/vdir/child"
                                                                              } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var mockGlobals = new Mock <IGlobals>();

            mockGlobals.Setup(x => x.ApplicationPath).Returns("/vdir");
            TestableGlobals.SetTestableInstance(mockGlobals.Object);

            var routeCollection = new RouteCollection();
            var srm             = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });

            //Assert
            Assert.AreEqual(2, routeCollection.Count);
            var urls = routeCollection.Cast <Route>().Select(x => x.Url).ToList();

            Assert.AreEqual(1, urls.Count(x => x.Contains("{prefix0}")));
            //if 2 urls and only 1 has prefix 0 then the other has no prefixesed wcon
        }
Exemplo n.º 6
0
        public void NameSpaceRequiredOnMapRouteCalls([ValueSource("_emptyStringArrays")] string[] namespaces)
        {
            var srm = new ServicesRoutingManager(new RouteCollection());

            Assert.Throws <ArgumentException>(() => srm.MapRoute("usm", "default", "url", null, namespaces));
        }
Exemplo n.º 7
0
        public void UniqueNameRequiredOnMapRouteCalls(string uniqueName)
        {
            var srm = new ServicesRoutingManager(new RouteCollection());

            Assert.Throws <ArgumentNullException>(() => srm.MapRoute(uniqueName, "default", "url", null, new[] { "foo" }));
        }
Exemplo n.º 8
0
        public void TwoRoutesOnTheSameFolderHaveSimilarNames()
        {
            //Arrange
            var portalInfo = new ArrayList { new PortalInfo { PortalID = 0 } };
            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);
            var mockPac = new Mock<IPortalAliasController>();
            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo { HTTPAlias = "www.foo.com" } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var routeCollection = new RouteCollection();
            var srm = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });
            srm.MapRoute("folder", "alt/url", new[] { "foo" });

            //Assert
            var route = (Route)routeCollection[0];
            Assert.AreEqual("folder-route0-instance0", route.DataTokens["Name"]);
            route = (Route)routeCollection[1];
            Assert.AreEqual("folder-route1-instance0", route.DataTokens["Name"]);
        }
Exemplo n.º 9
0
        public void NameSpaceRequiredOnMapRouteCalls([ValueSource("_emptyStringArrays")] string[] namespaces)
        {
            var srm = new ServicesRoutingManager(new RouteCollection());

            Assert.Throws<ArgumentException>(() => srm.MapRoute("usm", "default", "url", null, namespaces));
        }
Exemplo n.º 10
0
        public void VirtualDirWithChild()
        {
            //Arrange
            var portalInfo = new ArrayList { new PortalInfo { PortalID = 0 } };
            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);

            var mockPac = new Mock<IPortalAliasController>();
            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo { HTTPAlias = "www.foo.com/vdir" }, new PortalAliasInfo{HTTPAlias = "www.foo.com/vdir/child"} });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var mockGlobals = new Mock<IGlobals>();
            mockGlobals.Setup(x => x.ApplicationPath).Returns("/vdir");
            TestableGlobals.SetTestableInstance(mockGlobals.Object);

            var routeCollection = new RouteCollection();
            var srm = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });

            //Assert
            Assert.AreEqual(2, routeCollection.Count);
            var urls = routeCollection.Cast<Route>().Select(x => x.Url).ToList();
            Assert.AreEqual(1, urls.Count(x => x.Contains("{prefix0}")));
            //if 2 urls and only 1 has prefix 0 then the other has no prefixesed wcon
        }
Exemplo n.º 11
0
        public void VirtualDirOnlyMakesRouteWithNoWildcardPrefix()  
        {
            //Arrange
            var portalInfo = new ArrayList { new PortalInfo { PortalID = 0 } };
            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);

            var mockPac = new Mock<IPortalAliasController>();
            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] { new PortalAliasInfo { HTTPAlias = "www.foo.com/vdir" } });
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);

            var mockGlobals = new Mock<IGlobals>();
            mockGlobals.Setup(x => x.ApplicationPath).Returns("/vdir");
            TestableGlobals.SetTestableInstance(mockGlobals.Object);

            var routeCollection = new RouteCollection();
            var srm = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] { "foo" });

            //Assert
            Assert.AreEqual(1, routeCollection.Count);
            var route = (Route)routeCollection[0];
            StringAssert.DoesNotStartWith("{", route.Url);
        }
Exemplo n.º 12
0
        public void SimpleDomainMakes1Route()
        {
            //Arrange
            var portalInfo = new ArrayList {new PortalInfo {PortalID = 0}};
            _mockPortalController.Setup(x => x.GetPortals()).Returns(portalInfo);
            var mockPac = new Mock<IPortalAliasController>();
            mockPac.Setup(x => x.GetPortalAliasByPortalId(0)).Returns(new[] {new PortalAliasInfo{HTTPAlias = "www.foo.com"}});
            TestablePortalAliasController.SetTestableInstance(mockPac.Object);
            
            var routeCollection = new RouteCollection();
            var srm = new ServicesRoutingManager(routeCollection);

            //Act
            srm.MapRoute("folder", "url", new[] {"foo"});

            //Assert
            Assert.AreEqual(1, routeCollection.Count);
        }
Exemplo n.º 13
0
        public void UrlCanStartWithSlash()
        {
            //Arrange
            _mockPortalController.Setup(x => x.GetPortals()).Returns(new ArrayList());
            
            //Act
            var srm = new ServicesRoutingManager(new RouteCollection());

            //Assert
            Assert.DoesNotThrow(() => srm.MapRoute("name", "/url", null, new[] { "foo" }));
        }
Exemplo n.º 14
0
        public void UniqueNameRequiredOnMapRouteCalls(string uniqueName)
        {
            var srm = new ServicesRoutingManager(new RouteCollection());

            Assert.Throws<ArgumentNullException>(() => srm.MapRoute(uniqueName, "default", "url", null, new[] {"foo"}));
        }