예제 #1
0
 private object[] GroupProducers(IEnumerable <InstanceProducer> producers, int level)
 {
     return((
                from producer in producers
                group producer by TypeGeneralizer.MakeTypePartiallyGenericUpToLevel(producer.ServiceType, level)
                into resultGroup
                select this.BuildProducerGroup(resultGroup.Key, resultGroup.ToArray(), level + 1))
            .ToArray());
 }
예제 #2
0
        public void MakeTypePartiallyGenericUpToLevel_FourLevelsDeepGenericTypeRequestingLevel4_ReturnsThatType()
        {
            // Arrange
            Type suppliedType = typeof(IEnumerable <HashSet <List <Collection <double> > > >);
            Type expectedType = typeof(IEnumerable <HashSet <List <Collection <double> > > >);

            // Act
            Type actualType = TypeGeneralizer.MakeTypePartiallyGenericUpToLevel(suppliedType, 4);

            // Assert
            Assert.AreEqual(expectedType, actualType);
        }
예제 #3
0
        public void MakeTypePartiallyGenericUpToLevel_FourLevelsDeepGenericTypeWithMultipleBranchesRequestingLevel3_ReturnsPartlyGenericTypeDefinition()
        {
            // Arrange
            Type   suppliedType = typeof(IEnumerable <HashSet <List <Tuple <double, int> > > >);
            string expectedType = "IEnumerable<HashSet<List<Tuple<T1, T2>>>>";

            // Act
            Type actualType = TypeGeneralizer.MakeTypePartiallyGenericUpToLevel(suppliedType, 3);

            // Assert
            Assert.AreEqual(expectedType, actualType.ToFriendlyName());
        }
예제 #4
0
        public void MakeTypePartiallyGenericUpToLevel_RequestingLevel0OnTypeWithGenericConstraint_ReturnsGenericTypeDefinition()
        {
            // Arrange
            Type inputType    = typeof(IQueryHandler <ConstraintQuery, IEnumerable <int> >);
            int  nestingLevel = 0;
            Type expectedType = typeof(IQueryHandler <,>);

            // Act
            Type actualType = TypeGeneralizer.MakeTypePartiallyGenericUpToLevel(inputType, nestingLevel);

            // Assert
            Assert.AreEqual(expectedType, actualType);
        }