public void SelectMethodsFromNullTypeThrows()
 {
     // Fixture setup
     var sut = new EnumerableFavoringConstructorQuery();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.SelectMethods(null));
     // Teardown
 }
 public void SutIsMethodQuery()
 {
     // Fixture setup
     // Exercise system
     var sut = new EnumerableFavoringConstructorQuery();
     // Verify outcome
     Assert.IsAssignableFrom<IMethodQuery>(sut);
     // Teardown
 }
 public void SelectMethodsFromTypeReturnsFirstMethodThatTakesEnumerableAsArgument(Type type)
 {
     var sut = new EnumerableFavoringConstructorQuery();
     // Exercise system
     var result = sut.SelectMethods(type);
     // Verify outcome
     var genericParameterType = type.GetGenericArguments().Single();
     Assert.True(result.First().Parameters.Any(p => typeof(IEnumerable<>).MakeGenericType(genericParameterType).IsAssignableFrom(p.ParameterType)));
     // Teardown
 }
 public void SelectMethodsFromTypeWithNoPublicConstructorReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new EnumerableFavoringConstructorQuery();
     var typeWithNoPublicConstructors = typeof(AbstractType);
     // Exercise system
     var result = sut.SelectMethods(typeWithNoPublicConstructors);
     // Verify outcome
     Assert.False(result.Any());
     // Teardown
 }
        public void SelectMethodsFromTypeReturnsAllAppropriateResults(Type type)
        {
            // Fixture setup
            var expectedConstructors = from ci in type.GetConstructors()
                                       let parameters = ci.GetParameters()
                                       select new ConstructorMethod(ci) as IMethod;

            var sut = new EnumerableFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);
            // Verify outcome
            Assert.True(expectedConstructors.All(m => result.Any(m.Equals)));
            // Teardown
        }
        public void SelectMethodsFromTypeReturnsCorrectlyOrderedResultWhenNoConstructorContainsEnumerableArguments(Type type)
        {
            // Fixture setup
            var expectedConstructors = from ci in type.GetConstructors()
                                       let parameters = ci.GetParameters()
                                       orderby parameters.Length ascending
                                       select new ConstructorMethod(ci) as IMethod;

            var sut = new EnumerableFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);
            // Verify outcome
            Assert.True(expectedConstructors.SequenceEqual(result));
            // Teardown
        }
 public void SelectMethodsPrefersSpecificEnumerableParameterOverDerivedParameter(Type type, Type expected)
 {
     // Fixture setup
     var sut = new EnumerableFavoringConstructorQuery();
     // Exercise system
     var result = sut.SelectMethods(type);
     // Verify outcome
     Assert.True(result.First().Parameters.Any(p => expected == p.ParameterType));
     // Teardown
 }