public void GetTypeResolutionService_Cached() { TypeResolutionConfiguration.SetCurrent(new TypeResolutionConfiguration(new DefaultTypeResolutionService())); var defaultService = ContextAwareTypeUtility.GetTypeResolutionService(); TypeResolutionConfiguration.SetCurrent(new TypeResolutionConfiguration(new DefaultTypeResolutionService())); var defaultService2 = ContextAwareTypeUtility.GetTypeResolutionService(); Assert.That(defaultService, Is.SameAs(defaultService2)); }
public void GetTypeResolutionService_ComesFromConfiguration() { var typeResolutionServiceStub = MockRepository.GenerateStub <ITypeResolutionService>(); TypeResolutionConfiguration.SetCurrent(new TypeResolutionConfiguration(typeResolutionServiceStub)); var defaultService = ContextAwareTypeUtility.GetTypeResolutionService(); Assert.That(defaultService, Is.SameAs(typeResolutionServiceStub)); }
public void GetTypeResolutionService_DesignModeContext() { var typeResolutionServiceStub = MockRepository.GenerateStub <ITypeResolutionService>(); var designerHostMock = MockRepository.GenerateStub <IDesignerHost>(); designerHostMock.Expect(_ => _.GetService(typeof(ITypeResolutionService))).Return(typeResolutionServiceStub); DesignerUtility.SetDesignMode(new StubDesignModeHelper(designerHostMock)); Assert.That(ContextAwareTypeUtility.GetTypeResolutionService(), Is.SameAs(typeResolutionServiceStub)); designerHostMock.VerifyAllExpectations(); }
public void SetUp() { _oldTypeDiscoveryService = ContextAwareTypeUtility.GetTypeDiscoveryService(); _oldTypeDiscoveryConfiguration = TypeDiscoveryConfiguration.Current; _oldTypeResolutionService = ContextAwareTypeUtility.GetTypeResolutionService(); _oldTypeResolutionConfiguration = TypeResolutionConfiguration.Current; PrivateInvoke.SetNonPublicStaticField( typeof(ContextAwareTypeUtility), "s_defaultTypeDiscoveryService", new Lazy <ITypeDiscoveryService> (() => TypeDiscoveryConfiguration.Current.CreateTypeDiscoveryService())); PrivateInvoke.SetNonPublicStaticField( typeof(ContextAwareTypeUtility), "s_defaultTypeResolutionService", new Lazy <ITypeResolutionService> (() => TypeResolutionConfiguration.Current.CreateTypeResolutionService())); DesignerUtility.ClearDesignMode(); TypeDiscoveryConfiguration.SetCurrent(new TypeDiscoveryConfiguration()); TypeResolutionConfiguration.SetCurrent(new TypeResolutionConfiguration(new DefaultTypeResolutionService())); }