Beispiel #1
0
        public void Throw_if_class_has_no_private_method_with_given_name()
        {
            //Arrange
            privateMethodFinder = new PrivateMethodFinder <NoPrivateMethodClass>();
            var privateMethodName = "PrivateMethod";

            //Assert
            Assert.Throws <InvalidOperationException>(
                () => privateMethodFinder.GetPrivateMethod(privateMethodName)
                );
        }
        public void Return_empty_array_if_class_has_no_private_methods()
        {
            //Arrange
            privateMethodsFinder = new PrivateMethodFinder <NoPrivateMembersClass>();

            //Act
            var methodsArray = privateMethodsFinder.GetPrivateMethods();

            //Assert
            Assert.Empty(methodsArray);
        }
        public void Return_methodinfo_array_if_class_has_private_method()
        {
            //Arrange
            privateMethodsFinder = new PrivateMethodFinder <PrivateMethodsClass>();

            //Act
            var methodsArray = privateMethodsFinder.GetPrivateMethods();

            //Assert
            Assert.Equal(2, methodsArray.Length);
        }
Beispiel #4
0
        public void Return_methodinfo_if_class_has_private_method_with_given_name()
        {
            //Arrange
            privateMethodFinder = new PrivateMethodFinder <PrivateMethodClass>();
            var privateMethodName = "PrivateMethod";

            //Act
            var privateMethod = privateMethodFinder.GetPrivateMethod(privateMethodName);

            //Assert
            Assert.Equal(privateMethodName, privateMethod.Name);
            Assert.Equal(typeof(void), privateMethod.ReturnType);
            Assert.True(privateMethod.IsPrivate);
        }
        public void Array_not_contains_inherited_private_methods()
        {
            //Arrange
            privateMethodsFinder = new PrivateMethodFinder <PrivateMethodSubClass>();

            //Act
            var methodsArray = privateMethodsFinder.GetPrivateMethods();

            //Assert
            Assert.Single(methodsArray);

            var targetMethod = methodsArray[0];

            Assert.Equal("PrivateMethod", targetMethod.Name);
            Assert.Equal(typeof(void), targetMethod.ReturnType);
        }
        public void Return_methodinfo_array_with_protected_methodinfo()
        {
            //Arrange
            privateMethodsFinder = new PrivateMethodFinder <ProtectedMethodClass>();

            //Act
            var methodsArray = privateMethodsFinder.GetPrivateMethods();

            //Assert
            Assert.Single(methodsArray);

            var returnedMethod = methodsArray[0];

            Assert.Equal("ProtectedMethod", returnedMethod.Name);
            Assert.Equal(typeof(void), returnedMethod.ReturnType);
        }
Beispiel #7
0
 public PrivateTester(IPrivateMethodFinder privateMethodFinder)
 {
     this.privateMethodFinder = privateMethodFinder;
 }