public void DesignerSerializationManager_Container_Set_GetReturnsExpected(IContainer value) { var manager = new SubDesignerSerializationManager { Container = value }; Assert.Same(value, manager.Container); Assert.Same(value, manager.GetService(typeof(IContainer))); // Set same. manager.Container = value; Assert.Same(value, manager.Container); Assert.Same(value, manager.GetService(typeof(IContainer))); }
public void DesignerSerializationManager_GetService_IContainer_ReturnsExpected(IServiceProvider provider, object expected) { var manager = new SubDesignerSerializationManager(provider); Assert.Same(expected, manager.GetService(typeof(IContainer))); Assert.Same(expected, ((IServiceProvider)manager).GetService(typeof(IContainer))); }
public void DesignerSerializationManager_GetService_NoProvider_ReturnsNull(Type serviceType) { var manager = new SubDesignerSerializationManager(); Assert.Null(manager.GetService(serviceType)); Assert.Null(((IServiceProvider)manager).GetService(serviceType)); }
public void DesignerSerializationManager_GetService_WithProvider_ReturnsExpected(Type serviceType) { var service = new object(); var mockServiceProvider = new Mock <IServiceProvider>(MockBehavior.Strict); mockServiceProvider .Setup(p => p.GetService(serviceType)) .Returns(service) .Verifiable(); var manager = new SubDesignerSerializationManager(mockServiceProvider.Object); Assert.Same(service, manager.GetService(serviceType)); mockServiceProvider.Verify(p => p.GetService(serviceType), Times.Once()); Assert.Same(service, ((IServiceProvider)manager).GetService(serviceType)); mockServiceProvider.Verify(p => p.GetService(serviceType), Times.Exactly(2)); }