public void GetType_ValidProvider_ReturnsExpected(string typeName, Type resolvedType, int typeDescriptionProviderServiceCount, bool supportedType, Type expected)
        {
            var mockTypeResolutionService = new Mock <ITypeResolutionService>(MockBehavior.Strict);

            mockTypeResolutionService
            .Setup(s => s.GetType(typeName))
            .Returns(resolvedType)
            .Verifiable();
            var mockTypeDescriptionProvider = new Mock <TypeDescriptionProvider>(MockBehavior.Strict);

            mockTypeDescriptionProvider
            .Setup(p => p.IsSupportedType(resolvedType))
            .Returns(supportedType)
            .Verifiable();
            var mockTypeDescriptionProviderService = new Mock <TypeDescriptionProviderService>(MockBehavior.Strict);

            mockTypeDescriptionProviderService
            .Setup(s => s.GetProvider(resolvedType))
            .Returns(mockTypeDescriptionProvider.Object)
            .Verifiable();
            var mockServiceProvider = new Mock <IServiceProvider>(MockBehavior.Strict);

            mockServiceProvider
            .Setup(p => p.GetService(typeof(IDesignerHost)))
            .Returns((IDesignerHost)null);
            mockServiceProvider
            .Setup(p => p.GetService(typeof(ITypeResolutionService)))
            .Returns(mockTypeResolutionService.Object)
            .Verifiable();
            mockServiceProvider
            .Setup(p => p.GetService(typeof(TypeDescriptionProviderService)))
            .Returns(mockTypeDescriptionProviderService.Object)
            .Verifiable();
            var manager = new SubDesignerSerializationManager(mockServiceProvider.Object);

            Assert.Same(expected, manager.GetType(typeName));
            mockServiceProvider.Verify(p => p.GetService(typeof(ITypeResolutionService)), Times.Once());
            mockTypeResolutionService.Verify(s => s.GetType(typeName), Times.Once());
            mockServiceProvider.Verify(p => p.GetService(typeof(TypeDescriptionProviderService)), Times.Exactly(typeDescriptionProviderServiceCount));
            mockTypeDescriptionProviderService.Verify(s => s.GetProvider(resolvedType), Times.Exactly(typeDescriptionProviderServiceCount));
            mockTypeDescriptionProvider.Verify(s => s.IsSupportedType(resolvedType), Times.Exactly(typeDescriptionProviderServiceCount));

            // Call again.
            Assert.Same(expected, manager.GetType(typeName));
            mockServiceProvider.Verify(p => p.GetService(typeof(ITypeResolutionService)), Times.Once());
            mockTypeResolutionService.Verify(s => s.GetType(typeName), Times.Exactly(2));
            mockServiceProvider.Verify(p => p.GetService(typeof(TypeDescriptionProviderService)), Times.Exactly(typeDescriptionProviderServiceCount * 2));
            mockTypeDescriptionProviderService.Verify(s => s.GetProvider(resolvedType), Times.Exactly(typeDescriptionProviderServiceCount * 2));
            mockTypeDescriptionProvider.Verify(s => s.IsSupportedType(resolvedType), Times.Exactly(typeDescriptionProviderServiceCount * 2));
        }
        public void DesignerSerializationManager_GetType_NullTypeName_ThrowsArgumentNullException()
        {
            var manager = new SubDesignerSerializationManager();

            Assert.Throws <ArgumentNullException>("typeName", () => manager.GetType(null));
        }
        public void DesignerSerializationManager_GetType_NoProvider_ReturnsExpected(string typeName, Type expected)
        {
            var manager = new SubDesignerSerializationManager();

            Assert.Same(expected, manager.GetType(typeName));
        }
        public void DesignerSerializationManager_GetType_InvalidProvider_ReturnsExpected(IServiceProvider provider)
        {
            var manager = new SubDesignerSerializationManager(provider);

            Assert.Equal(typeof(int), manager.GetType(typeof(int).FullName));
        }