Esempio n. 1
0
        public void Test_PutValue_DottedAspect_Success()
        {
            // Arrange
            TestSubClass instance  = new TestSubClass();
            string       testValue = "some test value";
            Munger       munger    = new Munger("This.This.VirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.VirtualTestProperty);
        }
Esempio n. 2
0
        public void Test_PutValue_NonVirtualProperty_CalledOnSubClass()
        {
            // Arrange
            TestSubClass instance  = new TestSubClass();
            string       testValue = "some test value";
            Munger       munger    = new Munger("NonVirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.NonVirtualTestProperty);
            Assert.IsTrue(instance.subClassPropertyModified);
        }
Esempio n. 3
0
        public void Test_PutValue_DottedAspect_UnknownAspect()
        {
            // Arrange
            TestBaseClass instance  = new TestBaseClass();
            string        testValue = "1234567890";

            instance.VirtualTestProperty = testValue;
            Munger munger = new Munger("This.VirtualTestProperty.UnknownProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.VirtualTestProperty);
        }
Esempio n. 4
0
        public void Test_PutValue_DottedAspect_CantModifyReadOnlyProperty()
        {
            // Arrange
            TestSubClass instance   = new TestSubClass();
            string       testValue  = "some test value";
            string       testValue2 = "some test value2";
            Munger       munger     = new Munger("This.This.ReadOnlyProperty");

            instance.SetReadOnlyProperty(testValue);
            Assert.AreEqual(testValue, instance.ReadOnlyProperty);

            // Act
            munger.PutValue(instance, testValue2);

            // Assert
            Assert.AreEqual(testValue, instance.ReadOnlyProperty);
        }
Esempio n. 5
0
        public void Test_PutValue_NonVirtualProperty_CalledOnBaseClass()
        {
            // Arrange
            TestBaseClass instance  = new TestSubClass();
            string        testValue = "some test value";
            Munger        munger    = new Munger("NonVirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Munger acts on the runtime type of the instance, so it (correctly)
            // calls the subclass' version of this property. The compiler
            // uses the declared type of the instance, so instance.NonVirtualTestProperty
            // returns null, which is correct but perhaps unexpected.

            // Assert
            Assert.AreEqual(null, instance.NonVirtualTestProperty);
            Assert.AreEqual(testValue, (instance as TestSubClass).NonVirtualTestProperty);
            Assert.IsTrue((instance as TestSubClass).subClassPropertyModified);
        }
        public void Test_PutValue_NonVirtualProperty_CalledOnBaseClass() {
            // Arrange
            TestBaseClass instance = new TestSubClass();
            string testValue = "some test value";
            Munger munger = new Munger("NonVirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Munger acts on the runtime type of the instance, so it (correctly)
            // calls the subclass' version of this property. The compiler
            // uses the declared type of the instance, so instance.NonVirtualTestProperty
            // returns null, which is correct but perhaps unexpected.

            // Assert
            Assert.AreEqual(null, instance.NonVirtualTestProperty);
            Assert.AreEqual(testValue, (instance as TestSubClass).NonVirtualTestProperty);
            Assert.IsTrue((instance as TestSubClass).subClassPropertyModified);
        }
        public void Test_PutValue_NonVirtualProperty_CalledOnSubClass() {
            // Arrange
            TestSubClass instance = new TestSubClass();
            string testValue = "some test value";
            Munger munger = new Munger("NonVirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.NonVirtualTestProperty);
            Assert.IsTrue(instance.subClassPropertyModified);
        }
        public void Test_PutValue_DottedAspect_CantModifyReadOnlyProperty() {
            // Arrange
            TestSubClass instance = new TestSubClass();
            string testValue = "some test value";
            string testValue2 = "some test value2";
            Munger munger = new Munger("This.This.ReadOnlyProperty");
            instance.SetReadOnlyProperty(testValue);
            Assert.AreEqual(testValue, instance.ReadOnlyProperty);

            // Act
            munger.PutValue(instance, testValue2);

            // Assert
            Assert.AreEqual(testValue, instance.ReadOnlyProperty);
        }
        public void Test_PutValue_DottedAspect_UnknownAspect() {
            // Arrange
            TestBaseClass instance = new TestBaseClass();
            string testValue = "1234567890";
            instance.VirtualTestProperty = testValue;
            Munger munger = new Munger("This.VirtualTestProperty.UnknownProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.VirtualTestProperty);
        }
        public void Test_PutValue_DottedAspect_Success() {
            // Arrange
            TestSubClass instance = new TestSubClass();
            string testValue = "some test value";
            Munger munger = new Munger("This.This.VirtualTestProperty");

            // Act
            munger.PutValue(instance, testValue);

            // Assert
            Assert.AreEqual(testValue, instance.VirtualTestProperty);
        }