Пример #1
0
        public void GetDefaultProperty_InvokeWithoutParent_ReturnsNull()
        {
            var descriptor = new SubCustomTypeDescriptor();

            Assert.Null(descriptor.GetDefaultProperty());

            // Call again.
            Assert.Null(descriptor.GetDefaultProperty());
        }
Пример #2
0
        public void GetDefaultProperty_InvokeWithParent_ReturnsExpected(PropertyDescriptor result)
        {
            var mockParentDescriptor = new Mock <ICustomTypeDescriptor>(MockBehavior.Strict);

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

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

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