示例#1
0
        public void Enum_ConnnectionStringDictionary(string conStringA, string conStringB)
        {
            var builder = new ContainerBuilder();

            var module = new ServForOracleModule <TestEnum>(new Dictionary <TestEnum, string>
            {
                { TestEnum.A, conStringA },
                { TestEnum.B, conStringB }
            });

            module.LoadInternal(builder);

            var container = builder.Build(ContainerBuildOptions.ExcludeDefaultModules);

            Assert.True(container.IsRegisteredWithKey <IServiceForOracle>(TestEnum.A));
            Assert.True(container.IsRegisteredWithKey <IDbConnectionFactory>(TestEnum.A));
            var serviceA = container.ResolveKeyed <IServiceForOracle>(TestEnum.A);

            Assert.NotNull(serviceA);

            Assert.True(container.IsRegisteredWithKey <IServiceForOracle>(TestEnum.B));
            Assert.True(container.IsRegisteredWithKey <IDbConnectionFactory>(TestEnum.B));
            var serviceB = container.ResolveKeyed <IServiceForOracle>(TestEnum.B);

            Assert.NotNull(serviceB);
        }
示例#2
0
        public void ConnnectionString(string connectionString)
        {
            var builder = new ContainerBuilder();

            var module = new ServForOracleModule(connectionString);

            module.LoadInternal(builder);

            var container = builder.Build(ContainerBuildOptions.ExcludeDefaultModules);

            Assert.True(container.IsRegistered <IServiceForOracle>());
            Assert.True(container.IsRegistered <IDbConnectionFactory>());

            var service = container.Resolve <IServiceForOracle>();

            Assert.NotNull(service);
        }
示例#3
0
        public void ConnnectionStringObjectDictionary(Dictionary <object, string> connectionStrings)
        {
            var builder = new ContainerBuilder();

            var module = new ServForOracleModule(connectionStrings);

            module.LoadInternal(builder);

            var container = builder.Build(ContainerBuildOptions.ExcludeDefaultModules);

            foreach (var conStr in connectionStrings)
            {
                Assert.True(container.IsRegisteredWithKey <IServiceForOracle>(conStr.Key));
                Assert.True(container.IsRegisteredWithKey <IDbConnectionFactory>(conStr.Key));
                var service = container.ResolveKeyed <IServiceForOracle>(conStr.Key);

                Assert.NotNull(service);
            }
        }