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.GetPortalAliasesByPortalId(0)).Returns(new[] { new PortalAliasInfo {
                                                                                    HTTPAlias = "www.foo.com"
                                                                                } });
            PortalAliasController.SetTestableInstance(mockPac.Object);

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

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

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

            Assert.AreEqual("folder-default-0", route.DataTokens["Name"]);
            route = (Route)routeCollection[1];
            Assert.AreEqual("folder-another-0", route.DataTokens["Name"]);
        }
Exemplo n.º 2
0
        public void ParentPortalOnVirtualDirReturnsAnEmptyPrefix()
        {
            // Arrange
            var mockPortalController = new Mock <IPortalController>();
            var portals = new ArrayList {
                new PortalInfo {
                    PortalID = 1
                }
            };

            mockPortalController.Setup(x => x.GetPortals()).Returns(portals);
            PortalController.SetTestableInstance(mockPortalController.Object);

            var mockPortalAliasController = new Mock <IPortalAliasController>();

            mockPortalAliasController.Setup(x => x.GetPortalAliasesByPortalId(It.IsAny <int>())).Returns(new[]
            {
                new PortalAliasInfo {
                    HTTPAlias = "valid.lvh.me/vdir"
                }
            });
            PortalAliasController.SetTestableInstance(mockPortalAliasController.Object);

            var mockGlobals = new Mock <IGlobals>();

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

            // Act
            List <int> prefixes = new PortalAliasRouteManager().GetRoutePrefixCounts().ToList();

            // Assert
            CollectionAssert.AreEquivalent(new[] { 0 }, prefixes);
        }
Exemplo n.º 3
0
        public void PrefixCountsCacheCanBeCleared()
        {
            // Arrange
            var mockPortalController = new Mock <IPortalController>();
            var portals = new ArrayList {
                new PortalInfo {
                    PortalID = 1
                }
            };

            mockPortalController.Setup(x => x.GetPortals()).Returns(portals);
            PortalController.SetTestableInstance(mockPortalController.Object);

            var mockPortalAliasController = new Mock <IPortalAliasController>();

            mockPortalAliasController.Setup(x => x.GetPortalAliasesByPortalId(It.IsAny <int>())).Returns(new[] { new PortalAliasInfo {
                                                                                                                     HTTPAlias = "valid.lvh.me"
                                                                                                                 } });
            PortalAliasController.SetTestableInstance(mockPortalAliasController.Object);

            var mockGlobals = new Mock <IGlobals>();

            mockGlobals.Setup(x => x.ApplicationPath).Returns(string.Empty);
            TestableGlobals.SetTestableInstance(mockGlobals.Object);

            // Act
            var parm = new PortalAliasRouteManager();

            parm.GetRoutePrefixCounts();
            parm.ClearCachedData();
            parm.GetRoutePrefixCounts();

            // Assert
            mockPortalController.Verify(x => x.GetPortals(), Times.Exactly(2));
        }
        public void RoutesShouldHaveBackwardCompability()
        {
            // Arrange
            var portalInfo = new ArrayList {
                new PortalInfo {
                    PortalID = 0
                }
            };

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

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

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

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

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

            Assert.AreEqual("folder-default-0", route.DataTokens["Name"]);
            route = (Route)routeCollection[1];
            Assert.AreEqual("folder-default-0-old", route.DataTokens["Name"]);
            Assert.IsTrue(route.Url.StartsWith("DesktopModules"));
        }
Exemplo n.º 5
0
        public void VirtralDirWithChildPortalHasABlankAndASinglePrefix()
        {
            // Arrange
            var mockPortalController = new Mock <IPortalController>();
            var portals = new ArrayList {
                new PortalInfo {
                    PortalID = 1
                }
            };

            mockPortalController.Setup(x => x.GetPortals()).Returns(portals);
            PortalController.SetTestableInstance(mockPortalController.Object);

            var mockPortalAliasController = new Mock <IPortalAliasController>();

            mockPortalAliasController.Setup(x => x.GetPortalAliasesByPortalId(It.IsAny <int>())).Returns(new[]
            {
                new PortalAliasInfo {
                    HTTPAlias = "valid.lvh.me/vdir"
                },
                new PortalAliasInfo {
                    HTTPAlias = "valid.lvh.me/vdir/child"
                },
            });
            PortalAliasController.SetTestableInstance(mockPortalAliasController.Object);

            var mockGlobals = new Mock <IGlobals>();

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

            // Act
            List <int> prefixes = new PortalAliasRouteManager().GetRoutePrefixCounts().ToList();

            // Assert
            CollectionAssert.AreEqual(new[] { 1, 0 }, prefixes);
        }