Beispiel #1
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")
                );
        }
Beispiel #2
0
        public void Throw_if_member_with_given_is_public()
        {
            //Arrange
            object @object = new PrivateFieldClass(10);

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

            //Assert
            var fieldName = "publicInt";

            Assert.Throws <PrivatePropertyException>(
                () => privateTester.SetPrivateField(@object, fieldName, 0)
                );
        }
Beispiel #3
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)
                );
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }