public void Constructed_select_query_CommandBuilder_throws_when_negative_CommandTimeout_is_used()
 {
     using (var context = new ConfiguredChipsContext(_serviceProvider, "KettleChips"))
     {
         Assert.Throws <ArgumentException>(() => context.Database.AsRelational().Connection.CommandTimeout = -5);
     }
 }
Пример #2
0
        public async void Constructed_update_statement_uses_default_commandTimeout_can_override_configured_in_context_async()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection()
                                  .AddSingleton <IModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider))
            {
                context.Database.EnsureCreated();

                context.Chips.Add(new KettleChips {
                    BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos"
                });
                await context.SaveChangesAsync();

                Assert.Equal(77, GlobalCommandTimeout);

                context.Database.SetCommandTimeout(88);

                context.Chips.Add(new KettleChips {
                    BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos"
                });
                await context.SaveChangesAsync();

                Assert.Equal(88, GlobalCommandTimeout);
            }
        }
        public void Keys_generated_in_batches(int count, int expected)
        {
            var loggerFactory   = new TestSqlLoggerFactory();
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection()
                                  .AddSingleton <ILoggerFactory>(loggerFactory)
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider))
            {
                context.Database.EnsureCreated();

                for (var i = 0; i < count; i++)
                {
                    context.Chips.Add(new KettleChips {
                        BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos " + i
                    });
                }
                context.SaveChanges();
            }

            Assert.Equal(expected, CountSqlLinesContaining("SELECT NEXT VALUE FOR"));
        }
Пример #4
0
        public void Constructed_select_query_honors_latest_configured_commandTimeout_configured_in_context()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                var commandBuilder = setupCommandBuilder(context);

                context.Database.AsRelational().Connection.CommandTimeout = 88;
                var relationalConnection = (RelationalConnection)context.Database.Connection;
                var command = commandBuilder.Build(relationalConnection);

                Assert.Equal(88, command.CommandTimeout);

                context.Database.AsRelational().Connection.CommandTimeout = 99;
                relationalConnection = (RelationalConnection)context.Database.Connection;
                var command2 = commandBuilder.Build(relationalConnection);

                Assert.Equal(99, command2.CommandTimeout);
            }
        }
Пример #5
0
 public void Constructed_select_query_CommandBuilder_throws_when_negative_CommandTimeout_is_used()
 {
     using (var context = new ConfiguredChipsContext(_fixture.ServiceProvider))
     {
         Assert.Throws <ArgumentException>(() => context.Database.SetCommandTimeout(-5));
     }
 }
Пример #6
0
        public void Constructed_select_query_honors_configured_commandTimeout_configured_in_context()
        {
            using (var context = new ConfiguredChipsContext(_fixture.ServiceProvider))
            {
                var commandBuilder = setupCommandBuilder();

                var command = commandBuilder.Build(context.GetService <IRelationalConnection>(), new Dictionary <string, object>());

                Assert.Equal(77, command.CommandTimeout);
            }
        }
Пример #7
0
        public void Constructed_select_query_CommandBuilder_uses_default_when_null()
        {
            using (var context = new ConfiguredChipsContext(_fixture.ServiceProvider))
            {
                var commandBuilder = SetupCommandBuilder();

                context.Database.SetCommandTimeout(null);
                var command = commandBuilder.Build(context.GetService <IRelationalConnection>(), new Dictionary <string, object>());

                Assert.Equal(new SqliteCommand().CommandTimeout, command.CommandTimeout);
            }
        }
        public void Constructed_select_query_honors_configured_commandTimeout_configured_in_context()
        {
            using (var context = new ConfiguredChipsContext(_serviceProvider, "KettleChips"))
            {
                var commandBuilder = setupCommandBuilder(context);

                var relationalConnection = context.Database.AsRelational().Connection;
                var command = commandBuilder.Build(relationalConnection, new Dictionary <string, object>());

                Assert.Equal(77, command.CommandTimeout);
            }
        }
        public void Constructed_select_query_honors_configured_commandTimeout_configured_in_context()
        {
            using (var context = new ConfiguredChipsContext(_serviceProvider, "KettleChips"))
            {
                var commandBuilder = setupCommandBuilder(context);

                var relationalConnection = context.Database.AsRelational().Connection;
                var command = commandBuilder.Build(relationalConnection, new Dictionary<string, object>());

                Assert.Equal(77, command.CommandTimeout);
            }
        }
Пример #10
0
        public void Constructed_select_query_CommandBuilder_throws_when_negative_CommandTimeout_is_used()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                Assert.Throws <ArgumentException>(() => context.Database.AsRelational().Connection.CommandTimeout = -5);
            }
        }
Пример #11
0
        public void Constructed_select_query_CommandBuilder_uses_default_when_null()
        {
            using (var context = new ConfiguredChipsContext(_fixture.ServiceProvider))
            {
                var commandBuilder = setupCommandBuilder();

                var relationalConnection = context.Database.AsRelational().Connection;
                context.Database.AsRelational().Connection.CommandTimeout = null;
                var command = commandBuilder.Build(relationalConnection, new Dictionary <string, object>());

                Assert.Equal(30, command.CommandTimeout);
            }
        }
Пример #12
0
        public void Constructed_select_query_honors_latest_configured_commandTimeout_configured_in_context()
        {
            using (var context = new ConfiguredChipsContext(_fixture.ServiceProvider))
            {
                var commandBuilder = setupCommandBuilder();

                context.Database.AsRelational().Connection.CommandTimeout = 88;
                var relationalConnection = context.Database.AsRelational().Connection;
                var command = commandBuilder.Build(relationalConnection, new Dictionary <string, object>());

                Assert.Equal(88, command.CommandTimeout);

                context.Database.AsRelational().Connection.CommandTimeout = 99;
                relationalConnection = context.Database.AsRelational().Connection;
                var command2 = commandBuilder.Build(relationalConnection, new Dictionary <string, object>());

                Assert.Equal(99, command2.CommandTimeout);
            }
        }
Пример #13
0
        public void Constructed_select_query_CommandBuilder_uses_default_when_null()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                var commandBuilder = setupCommandBuilder(context);

                var relationalConnection = (RelationalConnection)context.Database.Connection;
                context.Database.AsRelational().Connection.CommandTimeout = null;
                var command = commandBuilder.Build(relationalConnection);

                Assert.Equal(30, command.CommandTimeout);
            }
        }
        public void Constructed_update_statement_uses_commandTimeout_overriding_configured_in_context()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection()
                                  .AddSingleton <SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                context.Database.EnsureCreated();

                context.Database.AsRelational().Connection.CommandTimeout = 88;
                context.Chips.Add(new KettleChips {
                    BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos"
                });
                context.SaveChanges();
                Assert.Equal(88, globalCommandTimeout);
            }
        }
Пример #15
0
        public async void Overridden_commandTimeout_overrides_timeout_configured_in_context_async()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFramework()
                                  .AddSqlServer()
                                  .ServiceCollection()
                                  .AddSingleton <IModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                                  .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider))
            {
                context.Database.EnsureCreated();

                context.Database.AsRelational().Connection.CommandTimeout = 88;

                context.Chips.Add(new KettleChips {
                    BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos"
                });
                await context.SaveChangesAsync();

                Assert.Equal(88, GlobalCommandTimeout);
            }
        }
 public void Constructed_select_query_CommandBuilder_throws_when_negative_CommandTimeout_is_used()
 {
     using (var context = new ConfiguredChipsContext(_serviceProvider, "KettleChips"))
     {
         Assert.Throws<ArgumentException>(() => context.Database.AsRelational().Connection.CommandTimeout = -5);
     }
 }
        public void Constructed_update_statement_uses_commandTimeout_configured_in_Context()
        {
            var serviceProvider = new ServiceCollection()
                .AddEntityFramework()
                .AddSqlServer()
                .ServiceCollection()
                .AddSingleton<SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                context.Database.EnsureCreated();

                context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos" });
                context.SaveChanges();
                Assert.Equal(77, globalCommandTimeout);
            }
        }
        public async void Overridden_commandTimeout_overrides_timeout_configured_in_context_async()
        {
            var serviceProvider = new ServiceCollection()
                .AddEntityFramework()
                .AddSqlServer()
                .ServiceCollection()
                .AddSingleton<SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                context.Database.EnsureCreated();

                context.Database.AsRelational().Connection.CommandTimeout = 88;

                context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos" });
                await context.SaveChangesAsync();
                Assert.Equal(88, globalCommandTimeout);
            }
        }
        public void Keys_generated_in_batches(int count, int expected)
        {
            var loggerFactory = new TestSqlLoggerFactory();
            var serviceProvider = new ServiceCollection()
                .AddEntityFramework()
                .AddSqlServer()
                .ServiceCollection()
                .AddInstance<ILoggerFactory>(loggerFactory)
                .AddSingleton<SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>()
                .BuildServiceProvider();

            using (var context = new ConfiguredChipsContext(serviceProvider, "KettleChips"))
            {
                context.Database.EnsureCreated();

                for (int i = 0; i < count; i++)
                {
                    context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos " + i });
                }
                context.SaveChanges();
            }

            Assert.Equal(expected, CountSqlLinesContaining("SELECT NEXT VALUE FOR"));
        }
        public void Constructed_select_query_CommandBuilder_uses_default_when_null()
        {
            using (var context = new ConfiguredChipsContext(_serviceProvider, "KettleChips"))
            {
                var commandBuilder = setupCommandBuilder(context);

                var relationalConnection = context.Database.AsRelational().Connection;
                context.Database.AsRelational().Connection.CommandTimeout = null;
                var command = commandBuilder.Build(relationalConnection, new Dictionary<string, object>());

                Assert.Equal(30, command.CommandTimeout);
            }
        }