public void Database_per_service_provider_is_default() { var provider1 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); var provider2 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); using (var context = new PusheenContext(nameof(PusheenContext), provider1)) { context.Add( new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext(nameof(PusheenContext), provider2)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext(nameof(PusheenContext), provider1)) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(nameof(PusheenContext), provider2)) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } }
public void Named_databases_shared_per_app_domain_with_internal_service_provider() { using (var context = new PusheenContext("Cats")) { context.Add( new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump")) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats")) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump")) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } }
public void Named_databases_shared_per_app_domain_with_internal_service_provider() { using (var context = new PusheenContext("Cats")) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump")) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats")) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump")) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } }
public void Database_per_service_provider_is_default() { var provider1 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); var provider2 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); using (var context = new PusheenContext(provider1)) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext(provider2)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext(provider1)) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(provider2)) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } }
public void Database_per_app_domain_is_default_with_internal_service_provider() { using (var context = new PusheenContext()) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext()) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } }
public void Database_per_app_domain_is_default_with_internal_service_provider() { using (var context = new PusheenContext(nameof(PusheenContext))) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext(nameof(PusheenContext))) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } }
public void Transient_databases_are_not_shared() { using (var context = new PusheenContext()) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext()) { Assert.Empty(context.Pusheens); } }
public void Named_databases_shared_per_service_provider() { var provider1 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); var provider2 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); using (var context = new PusheenContext("Cats", provider1)) { context.Add( new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump", provider1)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext(nameof(PusheenContext), provider1)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "On a scooter" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats", provider2)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "Is a DJ" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump", provider2)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "Goes to sleep" }); context.SaveChanges(); } using (var context = new PusheenContext(nameof(PusheenContext), provider2)) { Assert.Empty(context.Pusheens); context.Add( new Pusheen { Activity = "Loves magic unicorns" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats", provider1)) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump", provider1)) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(nameof(PusheenContext), provider1)) { Assert.Equal("On a scooter", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Cats", provider2)) { Assert.Equal("Is a DJ", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump", provider2)) { Assert.Equal("Goes to sleep", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(nameof(PusheenContext), provider2)) { Assert.Equal("Loves magic unicorns", context.Pusheens.Single().Activity); } }
public void Named_databases_shared_per_service_provider() { var provider1 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); var provider2 = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(); using (var context = new PusheenContext("Cats", provider1)) { context.Add(new Pusheen { Activity = "In a box" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump", provider1)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } using (var context = new PusheenContext(provider1)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "On a scooter" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats", provider2)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "Is a DJ" }); context.SaveChanges(); } using (var context = new PusheenContext("Plump", provider2)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "Goes to sleep" }); context.SaveChanges(); } using (var context = new PusheenContext(provider2)) { Assert.Empty(context.Pusheens); context.Add(new Pusheen { Activity = "Loves magic unicorns" }); context.SaveChanges(); } using (var context = new PusheenContext("Cats", provider1)) { Assert.Equal("In a box", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump", provider1)) { Assert.Equal("With some yarn", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(provider1)) { Assert.Equal("On a scooter", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Cats", provider2)) { Assert.Equal("Is a DJ", context.Pusheens.Single().Activity); } using (var context = new PusheenContext("Plump", provider2)) { Assert.Equal("Goes to sleep", context.Pusheens.Single().Activity); } using (var context = new PusheenContext(provider2)) { Assert.Equal("Loves magic unicorns", context.Pusheens.Single().Activity); } }