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

            var sut = new ListFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectConstructors(type);
            // Verify outcome
            Assert.True(expectedConstructors.All(m => result.Any(m.Equals)));
            // Teardown
        }
 public void SelectMethodsPrefersSpecificListParameterOverDerivedParameter(Type type)
 {
     // Fixture setup
     var sut = new ListFavoringConstructorQuery();
     // Exercise system
     var result = sut.SelectMethods(type);
     // Verify outcome
     Assert.True(result.First().Parameters.Any(p => typeof(IList<object>) == p.ParameterType));
     // 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 ListFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);
            // Verify outcome
            Assert.True(expectedConstructors.SequenceEqual(result));
            // Teardown
        }