public void Can_use_Firebird_default_values() { using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var honeyDijon = context.Add( new KettleChips { Name = "Honey Dijon" }).Entity; var buffaloBleu = context.Add( new KettleChips { Name = "Buffalo Bleu", BestBuyDate = DateTime.Parse("11/01/2111", CultureInfo.InvariantCulture) }).Entity; context.SaveChanges(); Assert.Equal(DateTime.Parse("09/25/2035", CultureInfo.InvariantCulture), honeyDijon.BestBuyDate); Assert.Equal(DateTime.Parse("11/01/2111", CultureInfo.InvariantCulture), buffaloBleu.BestBuyDate); } using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { Assert.Equal(DateTime.Parse("09/25/2035", CultureInfo.InvariantCulture), context.Chips.Single(c => c.Name == "Honey Dijon").BestBuyDate); Assert.Equal(DateTime.Parse("11/01/2111", CultureInfo.InvariantCulture), context.Chips.Single(c => c.Name == "Buffalo Bleu").BestBuyDate); } }
public void Dispose() { using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { context.Database.EnsureDeleted(); } }
public void Can_use_SQL_Server_default_values() { using (var context = new ChipsContext(_serviceProvider, TestStore.Name)) { context.Database.EnsureCreated(); context.Chippers.Add(new Chipper { Id = "Default" }); context.SaveChanges(); var honeyDijon = context.Add(new KettleChips { Name = "Honey Dijon" }).Entity; var buffaloBleu = context.Add(new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11) }).Entity; context.SaveChanges(); Assert.Equal(new DateTime(2035, 9, 25), honeyDijon.BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11), buffaloBleu.BestBuyDate); } using (var context = new ChipsContext(_serviceProvider, TestStore.Name)) { Assert.Equal(new DateTime(2035, 9, 25), context.Chips.Single(c => c.Name == "Honey Dijon").BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11), context.Chips.Single(c => c.Name == "Buffalo Bleu").BestBuyDate); } }
public async void Constructed_update_statement_uses_default_commandTimeout_can_override_not_configured_in_context_async() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlServer() .ServiceCollection() .AddSingleton <IModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>() .BuildServiceProvider(); using (var context = new ChipsContext(serviceProvider)) { context.Database.EnsureCreated(); context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos" }); await context.SaveChangesAsync(); Assert.Null(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 Can_use_Npgsql_default_values() { using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var honeyDijon = context.Add(new KettleChips { Name = "Honey Dijon" }).Entity; var buffaloBleu = context.Add(new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11, 0, 0, 0, DateTimeKind.Utc) }).Entity; context.SaveChanges(); Assert.Equal(new DateTime(2035, 9, 25, 0, 0, 0, DateTimeKind.Utc), honeyDijon.BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11, 0, 0, 0, DateTimeKind.Utc), buffaloBleu.BestBuyDate); } using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { Assert.Equal(new DateTime(2035, 9, 25, 0, 0, 0, DateTimeKind.Utc), context.Chips.Single(c => c.Name == "Honey Dijon").BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11, 0, 0, 0, DateTimeKind.Utc), context.Chips.Single(c => c.Name == "Buffalo Bleu").BestBuyDate); } }
public void Dispose() { using (var context = new ChipsContext(ServiceProvider)) { context.Database.EnsureDeleted(); } }
public void Can_use_SQL_Server_default_values() { using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var honeyDijon = context.Add(new KettleChips { Name = "Honey Dijon" }).Entity; context.SaveChanges(); Assert.Equal(new DateTime(2035, 9, 25), honeyDijon.BestBuyDate); var buffaloBleu = context.Add(new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11) }).Entity; context.SaveChanges(); Assert.Equal(new DateTime(2111, 1, 11), buffaloBleu.BestBuyDate); } using (var context = new ChipsContext(_serviceProvider, "DefaultKettleChips")) { Assert.Equal(new DateTime(2035, 9, 25), context.Chips.Single(c => c.Name == "Honey Dijon").BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11), context.Chips.Single(c => c.Name == "Buffalo Bleu").BestBuyDate); } }
public virtual void CreateDatabase() { _store = SqliteTestStore.GetOrCreateShared(DatabaseName, () => { using (var context = new ChipsContext(ServiceProvider)) { context.Database.EnsureClean(); } }); }
public virtual void CreateDatabase() { SqlServerTestStore.GetOrCreateShared(DatabaseName, () => { using (var context = new ChipsContext(ServiceProvider)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); } }); }
public void SampleUsage() { using (var context = new ChipsContext("chips")) { context.Database.EnsureCreated(); context.Add(new PringleChips { Id = Guid.NewGuid().ToString(), Name = "Honey Dijon" }); context.Add(new PringleChips { Id = Guid.NewGuid().ToString(), Name = "Ranch", BestBuyDate = new DateTime(2112, 2, 22) }); context.SaveChanges(); } }
public void Constructed_select_query_uses_default_when_CommandTimeout_not_configured_and_can_be_changed() { using (var context = new ChipsContext(_fixture.ServiceProvider)) { var commandBuilder = SetupCommandBuilder(); var command = commandBuilder.Build(context.GetService <IRelationalConnection>(), new Dictionary <string, object>()); Assert.Equal(new SqliteCommand().CommandTimeout, command.CommandTimeout); context.Database.SetCommandTimeout(77); var command2 = commandBuilder.Build(context.GetService <IRelationalConnection>(), new Dictionary <string, object>()); Assert.Equal(77, command2.CommandTimeout); } }
public void Constructed_select_query_uses_default_when_commandTimeout_not_configured_and_can_be_changed() { using (var context = new ChipsContext(_fixture.ServiceProvider)) { var commandBuilder = setupCommandBuilder(); var relationalConnection = context.Database.AsRelational().Connection; var command = commandBuilder.Build(relationalConnection, new Dictionary <string, object>()); Assert.Equal(30, command.CommandTimeout); context.Database.AsRelational().Connection.CommandTimeout = 77; var command2 = commandBuilder.Build(relationalConnection, new Dictionary <string, object>()); Assert.Equal(77, command2.CommandTimeout); } }
public void Constructed_select_query_uses_default_when_commandTimeout_not_configured_and_can_be_changed() { using (var context = new ChipsContext(_serviceProvider, "KettleChips")) { var commandBuilder = setupCommandBuilder(context); var relationalConnection = context.Database.AsRelational().Connection; var command = commandBuilder.Build(relationalConnection, new Dictionary<string, object>()); Assert.Equal(30, command.CommandTimeout); context.Database.AsRelational().Connection.CommandTimeout = 77; var command2 = commandBuilder.Build(relationalConnection, new Dictionary<string, object>()); Assert.Equal(77, command2.CommandTimeout); } }
public void Constructed_update_statement_uses_default_when_CommandTimeout_not_configured() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlite() .ServiceCollection() .AddScoped <SqliteModificationCommandBatchFactory, TestSqliteModificationCommandBatchFactory>() .BuildServiceProvider(); using (var context = new ChipsContext(serviceProvider)) { context.Database.EnsureCreated(); context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos" }); context.SaveChanges(); Assert.Null(GlobalCommandTimeout); } }
public void Constructed_update_statement_uses_commandTimeout_not_configured_in_context() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlServer() .ServiceCollection() .AddSingleton <SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>() .BuildServiceProvider(); using (var context = new ChipsContext(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); } }
public void Constructed_select_query_uses_default_when_commandTimeout_not_configured_and_can_be_changed() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlServer() .ServiceCollection .BuildServiceProvider(); using (var context = new ChipsContext(serviceProvider, "KettleChips")) { var commandBuilder = setupCommandBuilder(context); var relationalConnection = (RelationalConnection)context.Database.Connection; var command = commandBuilder.Build(relationalConnection); Assert.Equal(30, command.CommandTimeout); context.Database.AsRelational().Connection.CommandTimeout = 77; var command2 = commandBuilder.Build(relationalConnection); Assert.Equal(77, command2.CommandTimeout); } }
public void Can_use_SQL_Server_default_values() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlServer() .UseLoggerFactory <LoggerFactory>() .ServiceCollection .BuildServiceProvider(); using (var context = new ChipsContext(serviceProvider, "KettleChips")) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var honeyDijon = context.Add(new KettleChips { Name = "Honey Dijon" }); context.SaveChanges(); Assert.Equal(new DateTime(2035, 9, 25), honeyDijon.BestBuyDate); var buffaloBleu = context.Add(new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11) }); context.SaveChanges(); Assert.Equal(new DateTime(2111, 1, 11), buffaloBleu.BestBuyDate); } using (var context = new ChipsContext(serviceProvider, "KettleChips")) { Assert.Equal(new DateTime(2035, 9, 25), context.Chips.Single(c => c.Name == "Honey Dijon").BestBuyDate); Assert.Equal(new DateTime(2111, 1, 11), context.Chips.Single(c => c.Name == "Buffalo Bleu").BestBuyDate); } }
public async void Constructed_update_statement_uses_default_commandTimeout_can_override_not_configured_in_context_async() { var serviceProvider = new ServiceCollection() .AddEntityFramework() .AddSqlServer() .ServiceCollection() .AddSingleton<SqlServerModificationCommandBatchFactory, TestSqlServerModificationCommandBatchFactory>() .BuildServiceProvider(); using (var context = new ChipsContext(serviceProvider, "KettleChips")) { context.Database.EnsureCreated(); context.Chips.Add(new KettleChips { BestBuyDate = DateTime.Now, Name = "Doritos Locos Tacos" }); await context.SaveChangesAsync(); Assert.Null(globalCommandTimeout); 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); } }