public void In_memory_DbSet_can_be_used_for_Attach() { var set = new InMemoryDbSet<Product>(); var product = new Product(); Assert.Same(product, set.Attach(product)); Assert.Same(product, set.Single()); }
public void In_memory_DbSet_can_be_used_for_Add() { var set = new InMemoryNonGenericDbSet<Product>(); var product = new Product(); Assert.Same(product, set.Add(product)); Assert.Same(product, set.ToList<Product>().Single()); }
public void In_memory_DbSet_can_be_used_for_Find() { var product = new Product { Id = 1 }; var set = new InMemoryNonGenericDbSet<Product>( new[] { product, new Product { Id = 2 } }, (d, k) => d.Single(p => p.Id == (int)k[0])); Assert.Same(product, set.Find(1)); }
public void In_memory_DbSet_can_be_used_for_Remove() { var set = new InMemoryDbSet<Product>(); var product = new Product(); set.Add(product); Assert.Same(product, set.Remove(product)); Assert.Empty(set); }
public async Task In_memory_DbSet_can_be_used_for_FindAsync() { var product = new Product { Id = 1 }; var set = new InMemoryDbSet<Product>( new[] { product, new Product { Id = 2 } }, (d, k) => d.Single(p => p.Id == (int)k[0])); Assert.Same(product, await set.FindAsync(1)); }