Esempio n. 1
0
        public void GetProperties_InvokeAttributesWithoutParent_ReturnsEmpty(Attribute[] attributes)
        {
            var descriptor = new SubCustomTypeDescriptor();

            Assert.Same(PropertyDescriptorCollection.Empty, descriptor.GetProperties(attributes));

            // Call again.
            Assert.Same(PropertyDescriptorCollection.Empty, descriptor.GetProperties(attributes));
        }
Esempio n. 2
0
        public void GetProperties_InvokeAttributesWithParent_ReturnsExpected(Attribute[] attributes, PropertyDescriptorCollection result)
        {
            var mockParentDescriptor = new Mock <ICustomTypeDescriptor>(MockBehavior.Strict);

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

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

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