Example #1
0
 public List <MemberTypeInfo> GetHubs()
 {
     return(hubmanager
            .GetHubs()
            .Select(hub =>
     {
         string reasonDeprecated;
         var isDeprecated = hub.HubType.IsDeprecated(out reasonDeprecated);
         return new MemberTypeInfo(
             hub.NameSpecified ? hub.Name : typeHelper.FirstCharLowered(hub.Name),
             isDeprecated, reasonDeprecated, hub.HubType.FullName, false);
     }).ToList());
 }
        public List <TypeInfo> GetHubs()
        {
            var items = new List <TypeInfo>();

            foreach (var hub in _hubmanager.GetHubs())
            {
                string name     = hub.NameSpecified ? hub.Name : _typeHelper.FirstCharLowered(hub.Name);
                string typename = hub.HubType.FullName;

                items.Add(new TypeInfo()
                {
                    Name = name, TypescriptType = typename
                });
            }

            return(items);
        }
Example #3
0
        public void GetValidHubsWithValidPredicate()
        {
            var resolver       = new DefaultDependencyResolver();
            var hubManager     = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub");

            Assert.NotNull(hubDescriptors);
            Assert.Equal(hubDescriptors.First().Name, "CoreTestHub");
        }
Example #4
0
        public void GetValidHubsWithInvalidPredicate()
        {
            var resolver       = new DefaultDependencyResolver();
            var hubManager     = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(descriptor => descriptor.Name == "CoreTestHub_INVALIDHUB_____");

            // Still have an ienumerable sequence
            Assert.NotNull(hubDescriptors);
            // But there's nothing in the ienumerable
            Assert.Empty(hubDescriptors);
        }
Example #5
0
        public void GetValidHubsWithoutPredicate()
        {
            var resolver       = new DefaultDependencyResolver();
            var hubManager     = new DefaultHubManager(resolver);
            var hubDescriptors = hubManager.GetHubs(predicate: null);

            Assert.NotNull(hubDescriptors);

            HubDescriptor coreTestHub = hubDescriptors.First(descriptor => descriptor.Name == "CoreTestHub");

            Assert.NotNull(coreTestHub);
        }
        public void GetHubsWithInvalidHubThrows()
        {
            var hub = new HubDescriptor()
            {
                Name = "this.is.not.valid"
            };
            var resolver = new DefaultDependencyResolver();

            resolver.Register(typeof(IHubDescriptorProvider), () => new TestHubDescriptorProvider(hub));
            var hubManager = new DefaultHubManager(resolver);

            var ex = Assert.Throws <InvalidOperationException>(() => hubManager.GetHubs());

            Assert.Equal(string.Format(Resources.Error_HubNameIsInvalid, hub.Name), ex.Message);
        }
        public void GetHubsDoesNotThrowIfPredicateSkipsInvalidHub()
        {
            var invalidHub = new HubDescriptor()
            {
                Name = "this.is.not.valid"
            };
            var validHub = new HubDescriptor()
            {
                Name = "thisisvalid"
            };
            var resolver = new DefaultDependencyResolver();

            resolver.Register(typeof(IHubDescriptorProvider), () => new TestHubDescriptorProvider(invalidHub, validHub));
            var hubManager = new DefaultHubManager(resolver);

            Assert.Collection(
                hubManager.GetHubs(h => !h.Name.Contains(".")),
                h => Assert.Equal(validHub.Name, h.Name));
        }