示例#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 CanSetPublicProperty()
        {
            var sut = new PropertyInvocationsMirror();

            sut.PublicProperty = 42;
            int fieldValue = sut.PublicPropertyField;

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

            Assert.AreEqual(nameof(PropertyInvocationsMirror.PublicProperty) + "_set", invocation.MemberName);
            Assert.AreEqual(typeof(PropertyInvocationsMirror).GetMirrorClass(), invocation.ContainingType.FullName);
        }
示例#3
0
        public void CanGetInternalProperty()
        {
            var sut = new PropertyInvocationsMirror();

            sut.PublicPropertyField = 42;
            int rv = sut.PublicProperty;

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

            Assert.AreEqual(nameof(PropertyInvocationsMirror.PublicProperty) + "_get", invocation.MemberName);
            Assert.AreEqual(typeof(PropertyInvocationsMirror).GetMirrorClass(), invocation.ContainingType.FullName);
        }
示例#4
0
        public void CanGetPrivateProperty()
        {
            var sut   = new PropertyInvocationsMirror();
            var value = new PropertyValueMirror {
                Value = 42
            };

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

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

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