Esempio n. 1
0
        public void CanDiscoverRoute()
        {
            // Arrange & Act
            var routes = LegacyRouteTableFactory.Create(new[] { typeof(MyComponent), });

            // Assert
            Assert.Equal("Test1", Assert.Single(routes.Routes).Template.TemplateText);
        }
Esempio n. 2
0
        public void CanDiscoverRoutes_WithInheritance()
        {
            // Arrange & Act
            var routes = LegacyRouteTableFactory.Create(new[] { typeof(MyComponent), typeof(MyInheritedComponent), });

            // Assert
            Assert.Collection(
                routes.Routes.OrderBy(r => r.Template.TemplateText),
                r => Assert.Equal("Test1", r.Template.TemplateText),
                r => Assert.Equal("Test2", r.Template.TemplateText));
        }
Esempio n. 3
0
        public void DoesNotCacheRouteTableForDifferentAssemblies()
        {
            // Arrange
            var routes1 = LegacyRouteTableFactory.Create(new[] { GetType().Assembly, });

            // Act
            var routes2 = LegacyRouteTableFactory.Create(new[] { GetType().Assembly, typeof(object).Assembly, });

            // Assert
            Assert.NotSame(routes1, routes2);
        }
Esempio n. 4
0
        public void CanCacheRouteTableWithDifferentAssembliesAndOrder()
        {
            // Arrange
            var routes1 = LegacyRouteTableFactory.Create(new[] { typeof(object).Assembly, GetType().Assembly, });

            // Act
            var routes2 = LegacyRouteTableFactory.Create(new[] { GetType().Assembly, typeof(object).Assembly, });

            // Assert
            Assert.Same(routes1, routes2);
        }
Esempio n. 5
0
        public void CanCacheRouteTable()
        {
            // Arrange
            var routes1 = LegacyRouteTableFactory.Create(new[] { GetType().Assembly, });

            // Act
            var routes2 = LegacyRouteTableFactory.Create(new[] { GetType().Assembly, });

            // Assert
            Assert.Same(routes1, routes2);
        }
Esempio n. 6
0
 public LegacyRouteTable Build()
 {
     try
     {
         var templatesByHandler = _routeTemplates
                                  .GroupBy(rt => rt.Handler)
                                  .ToDictionary(group => group.Key, group => group.Select(g => g.Template).ToArray());
         return(LegacyRouteTableFactory.Create(templatesByHandler));
     }
     catch (InvalidOperationException ex) when(ex.InnerException is InvalidOperationException)
     {
         // ToArray() will wrap our exception in its own.
         throw ex.InnerException;
     }
 }