public void RegisterSqlServerConnection_Requires_Config()
        {
            // arrange
            ContainerBuilder cb = new ContainerBuilder();

            // act & assert
            Assert.Throws <ArgumentNullException>(() => SqlServerContainerBuilderExtensions.RegisterSqlServerConnection(cb, null));
        }
        public void RegisterSqlServerConnection_Requires_Builder()
        {
            // arrange
            IConfiguration config = new ConfigurationBuilder().Build();

            // act & assert
            Assert.Throws <ArgumentNullException>(() => SqlServerContainerBuilderExtensions.RegisterSqlServerConnection(null, config));
        }
示例#3
0
        public static IContainer Initialize()
        {
            ServerConfig.RegisterConfig("development");

            var container = new Container();

            SqlServerContainerBuilderExtensions.RegisterSqlServerConnection(container, ServerConfig.Configuration);

            return(container);
        }
        public void RegisterSqlServerConnection_AddsToContainer()
        {
            // arrange
            ContainerBuilder container = new ContainerBuilder();
            IConfiguration   config    = new ConfigurationBuilder().Build();

            // act
            var regBuilder = SqlServerContainerBuilderExtensions.RegisterSqlServerConnection(container, config);
            var services   = container.Build();
            var dbConn     = services.Resolve <IDbConnection>();

            // assert
            Assert.NotNull(dbConn);
            Assert.IsType <SqlConnection>(dbConn);
        }
        public void RegisterSqlServerConnection_AddsHealthContributorToContainer()
        {
            // arrange
            ContainerBuilder container = new ContainerBuilder();
            IConfiguration   config    = new ConfigurationBuilder().Build();

            // act
            var regBuilder        = SqlServerContainerBuilderExtensions.RegisterSqlServerConnection(container, config);
            var services          = container.Build();
            var healthContributor = services.Resolve <IHealthContributor>();

            // assert
            Assert.NotNull(healthContributor);
            Assert.IsType <RelationalHealthContributor>(healthContributor);
        }