Exemplo n.º 1
0
        public void GetRuntimeType_InvokeWithoutParentSystemDefinedType_ReturnsSame(Type reflectionType)
        {
            var provider = new SubTypeDescriptionProvider();

            Assert.Same(reflectionType, provider.GetRuntimeType(reflectionType));

            // Call again.
            Assert.Same(reflectionType, provider.GetRuntimeType(reflectionType));
        }
Exemplo n.º 2
0
        public void GetRuntimeType_InvokeWithParent_ReturnsExpected(Type reflectionType, Type result)
        {
            var mockParentProvider = new Mock <TypeDescriptionProvider>(MockBehavior.Strict);

            mockParentProvider
            .Setup(p => p.GetRuntimeType(reflectionType))
            .Returns(result)
            .Verifiable();
            var provider = new SubTypeDescriptionProvider(mockParentProvider.Object);

            Assert.Same(result, provider.GetRuntimeType(reflectionType));
            mockParentProvider.Verify(p => p.GetRuntimeType(reflectionType), Times.Once());

            // Call again.
            Assert.Same(result, provider.GetRuntimeType(reflectionType));
            mockParentProvider.Verify(p => p.GetRuntimeType(reflectionType), Times.Exactly(2));
        }
Exemplo n.º 3
0
        public void GetRuntimeType_InvokeWithoutParentWithUserDefinedType_RetunsUnderlyingSystemType(Type result)
        {
            var mockType = new Mock <Type>(MockBehavior.Strict);

            mockType
            .Setup(t => t.UnderlyingSystemType)
            .Returns(result)
            .Verifiable();
            var provider = new SubTypeDescriptionProvider();

            Assert.Same(result, provider.GetRuntimeType(mockType.Object));
            mockType.Verify(t => t.UnderlyingSystemType, Times.Once());

            // Call again.
            Assert.Same(result, provider.GetRuntimeType(mockType.Object));
            mockType.Verify(t => t.UnderlyingSystemType, Times.Exactly(2));
        }
Exemplo n.º 4
0
        public void GetRuntimeType_NullReflectionType_ThrowsArgumentNullException()
        {
            var provider = new SubTypeDescriptionProvider();

            AssertExtensions.Throws <ArgumentNullException>("reflectionType", () => provider.GetRuntimeType(null));
        }