Exemple #1
0
        public void GetConverter_InvokeWithoutParent_ReturnsExpected()
        {
            var           descriptor = new SubCustomTypeDescriptor();
            TypeConverter result1    = Assert.IsType <TypeConverter>(descriptor.GetConverter());

            Assert.NotNull(result1);

            // Call again.
            TypeConverter result2 = Assert.IsType <TypeConverter>(descriptor.GetConverter());

            Assert.NotSame(result1, result2);
        }
Exemple #2
0
        public void GetConverter_InvokeWithParent_ReturnsExpected(TypeConverter result)
        {
            var mockParentDescriptor = new Mock <ICustomTypeDescriptor>(MockBehavior.Strict);

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

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

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