public void GetExtendedTypeDescriptor_InvokeWithParent_ReturnsExpected(object instance, ICustomTypeDescriptor result) { var mockParentProvider = new Mock <TypeDescriptionProvider>(MockBehavior.Strict); mockParentProvider .Setup(p => p.GetExtendedTypeDescriptor(instance)) .Returns(result) .Verifiable(); var provider = new SubTypeDescriptionProvider(mockParentProvider.Object); Assert.Same(result, provider.GetExtendedTypeDescriptor(instance)); mockParentProvider.Verify(p => p.GetExtendedTypeDescriptor(instance), Times.Once()); // Call again. Assert.Same(result, provider.GetExtendedTypeDescriptor(instance)); mockParentProvider.Verify(p => p.GetExtendedTypeDescriptor(instance), Times.Exactly(2)); }
public void GetExtendedTypeDescriptor_InvokeWithoutParent_ReturnsExpected(object instance) { var provider = new SubTypeDescriptionProvider(); CustomTypeDescriptor result1 = Assert.IsAssignableFrom <CustomTypeDescriptor>(provider.GetExtendedTypeDescriptor(instance)); Assert.Empty(result1.GetProperties()); // Call again. CustomTypeDescriptor result2 = Assert.IsAssignableFrom <CustomTypeDescriptor>(provider.GetExtendedTypeDescriptor(instance)); Assert.Same(result1, result2); }