コード例 #1
0
        public void CanGetReadonlyProperty()
        {
            var sut = new PropertyInvocationsMirror();

            PropertyValueMirror rv = sut.PrivateReadonlyProperty;

            Assert.IsInstanceOfType(rv, typeof(PropertyValueMirror));
            Assert.AreEqual(24, rv.Value);
        }
コード例 #2
0
        public void CanGetPrivateStaticProperty()
        {
            var value = new PropertyValueMirror {
                Value = 42
            };

            PropertyInvocationsMirror.PrivateStaticPropertyField = value;
            PropertyValueMirror rv = PropertyInvocationsMirror.PrivateStaticProperty;

            Assert.AreEqual(42, rv.Value);
            var invocation = MethodInvocation.Invocations.Single();

            Assert.AreEqual(nameof(PropertyInvocationsMirror.PrivateStaticProperty) + "_get", invocation.MemberName);
            Assert.AreEqual(typeof(PropertyInvocationsMirror).GetMirrorClass(), invocation.ContainingType.FullName);
        }
コード例 #3
0
        public void CanSetPrivateProperty()
        {
            var sut   = new PropertyInvocationsMirror();
            var value = new PropertyValueMirror {
                Value = 42
            };

            sut.PrivateProperty = value;
            PropertyValueMirror fieldValue = sut.PrivatePropertyField;

            Assert.AreEqual(42, fieldValue.Value);
            var invocation = MethodInvocation.Invocations.Single();

            Assert.AreEqual(nameof(PropertyInvocationsMirror.PrivateProperty) + "_set", invocation.MemberName);
            Assert.AreEqual(typeof(PropertyInvocationsMirror).GetMirrorClass(), invocation.ContainingType.FullName);
        }