Esempio n. 1
0
        public void GetPropertyOwner_InvokeWithoutParent_ReturnsNull(PropertyDescriptor pd)
        {
            var descriptor = new SubCustomTypeDescriptor();

            Assert.Null(descriptor.GetPropertyOwner(pd));

            // Call again.
            Assert.Null(descriptor.GetPropertyOwner(pd));
        }
Esempio n. 2
0
        public void GetPropertyOwner_InvokeWithParent_ReturnsExpected(PropertyDescriptor pd, object result)
        {
            var mockParentDescriptor = new Mock <ICustomTypeDescriptor>(MockBehavior.Strict);

            mockParentDescriptor
            .Setup(d => d.GetPropertyOwner(pd))
            .Returns(result)
            .Verifiable();
            var descriptor = new SubCustomTypeDescriptor(mockParentDescriptor.Object);

            Assert.Same(result, descriptor.GetPropertyOwner(pd));
            mockParentDescriptor.Verify(d => d.GetPropertyOwner(pd), Times.Once());

            // Call again.
            Assert.Same(result, descriptor.GetPropertyOwner(pd));
            mockParentDescriptor.Verify(d => d.GetPropertyOwner(pd), Times.Exactly(2));
        }