public void WhenUsingDefaultStrategyList_ThenCryptoBlockProviderIsNotReturned()
        {
            var locator       = TypeRegistrationsProvider.CreateDefaultProvider();
            var registrations = locator.GetRegistrations(configSource)
                                .Where(r => r.ServiceType == typeof(IHashProvider));

            Assert.AreEqual(0, registrations.Count());
        }
        public void WhenUsingDefaultLocators_ThenDataProviderIsReturned()
        {
            locator = TypeRegistrationsProvider.CreateDefaultProvider();

            var registrations = locator.GetRegistrations(configSource)
                                .Where(r => r.ServiceType == typeof(Database));

            Assert.AreEqual(1, registrations.Count());
        }
        public void WhenUsingDefaultStrategyList_ThenEHABAndCryptoProvidersAreReturned()
        {
            var locator = TypeRegistrationsProvider.CreateDefaultProvider();

            var registrations = locator.GetRegistrations(configSource)
                                .Where(r => r.ServiceType == typeof(IHashProvider) || r.ServiceType == typeof(ExceptionPolicyImpl));

            Assert.AreEqual(3, registrations.Count());
        }
        /// <summary>
        /// Read the current Enterprise Library configuration in the given <paramref name="configSource"/>
        /// and supply the corresponding type information to the <paramref name="configurator"/>.
        /// </summary>
        /// <param name="configurator"><see cref="IContainerConfigurator"/> object used to consume the configuration
        /// information.</param>
        /// <param name="configSource">Configuration information.</param>
        public static void ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource)
        {
            var reconfiguringEventSource = configurator as IContainerReconfiguringEventSource ??
                                           new NullContainerReconfiguringEventSource();


            ConfigureContainer(
                TypeRegistrationsProvider.CreateDefaultProvider(configSource, reconfiguringEventSource),
                configurator,
                configSource);
        }
Пример #5
0
        public void Given()
        {
            var configSource            = new DictionaryConfigurationSource();
            var mockEventSourceProvider = new Mock <IContainerReconfiguringEventSource>();

            var builder = new SectionBuilder();

            builder.LocatorSection()
            .AddProvider <MockSection>().WithProviderName("SomeName")
            .AddTo(configSource);

            var eventArgs = new Mock <ContainerReconfiguringEventArgs>(configSource, new[] { "NotUsed" });
            var provider  = TypeRegistrationsProvider.CreateDefaultProvider(configSource, mockEventSourceProvider.Object);

            MockSection.UpdatedRegistrationsWasCalled = false;
            mockEventSourceProvider.Raise(e => e.ContainerReconfiguring += null, eventArgs.Object);
        }
        public void StartCacheProcesses()
        {
            sharedLock       = new object();
            callbackCount    = 0;
            callbackReason   = CacheItemRemovedReason.Unknown;
            exceptionMessage = "";

            var defaultProvider = TypeRegistrationsProvider.CreateDefaultProvider();

            var registrationProvider = new CompositeTypeRegistrationsProviderLocator(defaultProvider, new RaceConditionSimulatingExpirationTaskRegistrationProvider());

            IUnityContainer     container           = new UnityContainer();
            var                 configurator        = new UnityContainerConfigurator(container);
            UnityServiceLocator unityServiceLocator = new UnityServiceLocator(container);

            EnterpriseLibraryContainer.ConfigureContainer(registrationProvider, configurator, TestConfigurationSource.GenerateConfiguration());

            cacheManager = (CacheManager)unityServiceLocator.GetInstance <ICacheManager>("ShortInMemoryPersistence");
        }
 public void Given()
 {
     configSource         = new ConfigSourceBuilder().AddExceptionHandlingSettings().ConfigSource;
     configSectionLocator = new ConfigSectionLocator(CryptographySettings.SectionName);
 }
 private ITypeRegistrationsProvider GetLocator(IConfigurationSource configSource)
 {
     return(TypeRegistrationsProvider.CreateDefaultProvider(configSource,
                                                            new NullContainerReconfiguringEventSource()));
 }