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 TearDown()
        {
            PrivateInvoke.SetNonPublicStaticField(
                typeof(ContextAwareTypeUtility),
                "s_defaultTypeDiscoveryService",
                new Lazy <ITypeDiscoveryService> (() => _oldTypeDiscoveryService));
            PrivateInvoke.SetNonPublicStaticField(
                typeof(ContextAwareTypeUtility),
                "s_defaultTypeResolutionService",
                new Lazy <ITypeResolutionService> (() => _oldTypeResolutionService));
            DesignerUtility.ClearDesignMode();

            TypeDiscoveryConfiguration.SetCurrent(_oldTypeDiscoveryConfiguration);
            TypeResolutionConfiguration.SetCurrent(_oldTypeResolutionConfiguration);
        }
        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()));
        }