コード例 #1
0
 public void SelectMethodsFromNullTypeThrows()
 {
     // Fixture setup
     var sut = new ArrayFavoringConstructorQuery();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.SelectMethods(null).ToList());
     // Teardown
 }
コード例 #2
0
        public void SelectMethodsFromNullTypeThrows()
        {
            // Arrange
            var sut = new ArrayFavoringConstructorQuery();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.SelectMethods(null).ToList());
        }
コード例 #3
0
        public void SelectMethodsFromTypeReturnsFirstMethodThatTakesArrayAsArgument(Type type)
        {
            // Arrange
            var sut = new ArrayFavoringConstructorQuery();
            // Act
            var result = sut.SelectMethods(type);

            // Assert
            Assert.Contains(result.First().Parameters, p => p.ParameterType.IsArray);
        }
コード例 #4
0
        public void DoesNotReturnConstructorsWithParametersOfEnclosingType()
        {
            // Arrange
            var sut = new ArrayFavoringConstructorQuery();
            // Act
            var result = sut.SelectMethods(typeof(TypeWithCopyConstructorsOnly));

            // Assert
            Assert.Empty(result);
        }
コード例 #5
0
        public void SelectMethodsFromNullTypeThrows()
        {
            // Fixture setup
            var sut = new ArrayFavoringConstructorQuery();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.SelectMethods(null).ToList());
            // Teardown
        }
コード例 #6
0
 public void SelectMethodsFromTypeReturnsFirstMethodThatTakesArrayAsArgument(Type type)
 {
     // Fixture setup
     var sut = new ArrayFavoringConstructorQuery();
     // Exercise system
     var result = sut.SelectMethods(type);
     // Verify outcome
     Assert.True(result.First().Parameters.Any(p => p.ParameterType.IsArray));
     // Teardown
 }
コード例 #7
0
        public void SelectFromTypeWithNoPublicConstructorReturnsCorrectResult()
        {
            // Arrange
            var sut = new ArrayFavoringConstructorQuery();
            var typeWithNoPublicConstructors = typeof(AbstractType);
            // Act
            var result = sut.SelectMethods(typeWithNoPublicConstructors);

            // Assert
            Assert.False(result.Any());
        }
コード例 #8
0
        public void SelectMethodsFromTypeReturnsFirstMethodThatTakesArrayAsArgument(Type type)
        {
            // Fixture setup
            var sut = new ArrayFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);

            // Verify outcome
            Assert.True(result.First().Parameters.Any(p => p.ParameterType.IsArray));
            // Teardown
        }
コード例 #9
0
 public void SelectFromTypeWithNoPublicConstructorReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new ArrayFavoringConstructorQuery();
     var typeWithNoPublicConstructors = typeof(AbstractType);
     // Exercise system
     var result = sut.SelectMethods(typeWithNoPublicConstructors);
     // Verify outcome
     Assert.False(result.Any());
     // Teardown
 }
コード例 #10
0
        public void SelectFromTypeWithNoPublicConstructorReturnsCorrectResult()
        {
            // Fixture setup
            var sut = new ArrayFavoringConstructorQuery();
            var typeWithNoPublicConstructors = typeof(AbstractType);
            // Exercise system
            var result = sut.SelectMethods(typeWithNoPublicConstructors);

            // Verify outcome
            Assert.False(result.Any());
            // Teardown
        }
コード例 #11
0
        public void SelectMethodsFromTypeReturnsAllAppropriateResults(Type type)
        {
            // Arrange
            var expectedConstructors = from ci in type.GetConstructors()
                                       let parameters = ci.GetParameters()
                                                        select new ConstructorMethod(ci) as IMethod;

            var sut = new ArrayFavoringConstructorQuery();
            // Act
            var result = sut.SelectMethods(type);

            // Assert
            Assert.True(expectedConstructors.All(m => result.Any(m.Equals)));
        }
コード例 #12
0
        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 ArrayFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);
            // Verify outcome
            Assert.True(expectedConstructors.All(m => result.Any(m.Equals)));
            // Teardown
        }
コード例 #13
0
        public void SelectMethodsFromTypeReturnsCorrectlyOrderedResultWhenNoConstructorContainsEnumerableArguments(Type type)
        {
            // Arrange
            var expectedConstructors = from ci in type.GetConstructors()
                                       let parameters = ci.GetParameters()
                                                        orderby parameters.Length ascending
                                                        select new ConstructorMethod(ci) as IMethod;

            var sut = new ArrayFavoringConstructorQuery();
            // Act
            var result = sut.SelectMethods(type);

            // Assert
            Assert.True(expectedConstructors.SequenceEqual(result));
        }
コード例 #14
0
        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 ArrayFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);

            // Verify outcome
            Assert.True(expectedConstructors.All(m => result.Any(m.Equals)));
            // Teardown
        }
コード例 #15
0
        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 ArrayFavoringConstructorQuery();
            // Exercise system
            var result = sut.SelectMethods(type);
            // Verify outcome
            Assert.True(expectedConstructors.SequenceEqual(result));
            // Teardown
        }