Ejemplo n.º 1
0
        public void Return_string_type_if_string_type_given()
        {
            //Arrange
            privateTester = new Core.PrivateTester <string>();

            //Act
            var type = privateTester.GetPrivateType();

            //Asssert
            Assert.Equal(typeof(string), type);
        }
Ejemplo n.º 2
0
        public void Return_10_if_value_of_private_field_is_10()
        {
            //Arrange
            object instance = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            //Act
            var fieldValue = privateTester.GetPrivateField(instance, "privateInt");

            //Assert
            Assert.Equal(10, fieldValue);
        }
Ejemplo n.º 3
0
        public void Throws_if_property_is_public()
        {
            //Arrange
            object @object = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            //Assert
            var fieldName = "publicInt";

            Assert.Throws <PrivatePropertyException>(
                () => privateTester.GetPrivateField(@object, fieldName)
                );
        }
Ejemplo n.º 4
0
        public void Throws_if_property_not_present()
        {
            //Arrange
            object @object = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            //Assert
            var fieldName = "nonExistingField";

            Assert.Throws <PrivatePropertyException>(
                () => privateTester.GetPrivateField(@object, fieldName)
                );
        }
Ejemplo n.º 5
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)
                );
        }
Ejemplo n.º 6
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)
                );
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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)
                );
        }
Ejemplo n.º 9
0
        public void Throw_if_invlaid_type_of_parameter_provided()
        {
            //Arrange
            object @object = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            //Assert
            var fieldName = "privateInt";

            Assert.Throws <PrivatePropertyException>(
                () => privateTester.SetPrivateField(@object, fieldName, "zero")
                );
        }
Ejemplo n.º 10
0
        public void Throw_if_member_with_given_name_not_presnt()
        {
            //Arrange
            object @object = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            //Assert
            var fieldName = "nonExistingField";

            Assert.Throws <PrivatePropertyException>(
                () => privateTester.SetPrivateField(@object, fieldName, 0)
                );
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public void Change_value_of_private_string()
        {
            //Arrange
            var instance = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            var currentPrivateStringValue = instance.GetPrivateString();

            Assert.Equal("nothing", currentPrivateStringValue);

            //Act
            privateTester.SetPrivateField(instance, "privateString", "value");

            //Assert
            currentPrivateStringValue = instance.GetPrivateString();
            Assert.Equal("value", currentPrivateStringValue);
        }
Ejemplo n.º 13
0
        public void Change_value_of_private_field()
        {
            //Arrange
            var instance = new PrivateFieldClass(10);

            privateTester = new Core.PrivateTester <PrivateFieldClass>();

            var currentPrivateIntValue = instance.GetPrivateInt();

            Assert.Equal(10, currentPrivateIntValue);

            //Act
            privateTester.SetPrivateField(instance, "privateInt", 12);

            //Assert
            currentPrivateIntValue = instance.GetPrivateInt();
            Assert.Equal(12, currentPrivateIntValue);
        }