public void DeleteManufacturer_EntityIsFound_ShouldReturnTrueAndRemoveOneEntry() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("19D1029C-8394-4D73-B8E2-14477D81BDAC").Options; using (var context = new ApplicationDbContext(options)) { context.AddRange(_manufacturers); context.SaveChanges(); } using (var context = new ApplicationDbContext(options)) using (var manufacturersRepository = new ManufacturerRepository(context)) { var result = manufacturersRepository.DeleteManufacturer(3); Assert.True(result); Assert.Equal(2, manufacturersRepository.Manufacturers.Count()); } }
public void DeleteManufacturer_EntityIsNull_ShouldReturnFalse() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("407579ED-65B4-4165-8ED9-662DE394D3EA").Options; using (var context = new ApplicationDbContext(options)) { context.AddRange(_manufacturers); context.SaveChanges(); } using (var context = new ApplicationDbContext(options)) using (var manufacturersRepository = new ManufacturerRepository(context)) { var result = manufacturersRepository.DeleteManufacturer(4); Assert.False(result); Assert.Equal(3, manufacturersRepository.Manufacturers.Count()); } }