コード例 #1
0
        public void Throw_if_method_require_parameter_but_no_parameter_provided()
        {
            //Arrange
            privateTester = new Core.PrivateTester <PrivateMethodClass>(
                new PrivateMethodFinder <PrivateMethodClass>()
                );

            //Assert
            var methodName = "PrivateMethodWithParameter";

            Assert.Throws <Core.InvalidArgumentListException>(
                () => privateTester.InvokePrivateMethod(methodName)
                );
        }
コード例 #2
0
        public void Throw_if_parameter_number_is_diffrent_than_required()
        {
            //Arrange
            privateTester = new Core.PrivateTester <PrivateMethodClass>(
                new PrivateMethodFinder <PrivateMethodClass>()
                );

            //Assert
            var methodName = "PrivateMethodWithParameter";

            Assert.Throws <Core.InvalidArgumentListException>(
                () => privateTester.InvokePrivateMethod(methodName, 1, 3)
                );
        }
コード例 #3
0
        public void Call_method_with_given_name()
        {
            //Arrange
            privateTester = new Core.PrivateTester <PrivateMethodClass>(
                new PrivateMethodFinder <PrivateMethodClass>()
                );

            //Act
            privateTester.InvokePrivateMethod("PrivateMethod");

            //Assert
            Assert.Equal(1, PrivateMethodClass.privateMethodCalls);
            Assert.Equal(0, PrivateMethodClass.publicMethodCalls);
        }
コード例 #4
0
        public void Throw_if_class_has_no_method_with_given_type()
        {
            //Arrange
            privateTester = new Core.PrivateTester <PrivateMethodClass>(
                new PrivateMethodFinder <PrivateMethodClass>()
                );

            //Assert
            var methodName = "NotExistentMethod";

            Assert.Throws <InvalidOperationException>(
                () => privateTester.InvokePrivateMethod(methodName)
                );
        }
コード例 #5
0
        public void Call_method_with_given_name_and_provide_parameters()
        {
            //Arrange
            privateTester = new Core.PrivateTester <PrivateMethodClass>(
                new PrivateMethodFinder <PrivateMethodClass>()
                );

            //Act
            privateTester.InvokePrivateMethod("PrivateMethodWithParameter", 1);

            //Assert
            Assert.Equal(1, PrivateMethodClass.privateMethodCalls);
            Assert.Equal(0, PrivateMethodClass.publicMethodCalls);
            Assert.Equal(1, PrivateMethodClass.passedParameter);
        }