public BottleSizeControllerTests() { // Create inMemory database for testing. _optionsBuilder = new DbContextOptionsBuilder <WineCellarDBContext>( ); _optionsBuilder.UseInMemoryDatabase("BottleSizeUnitTestInMemDB"); _dbContext = new WineCellarDBContext(_optionsBuilder.Options); // Create commands controller for testing. _controller = new BottleSizeController(_dbContext, new NullLogger <BottleSizeController>( )); }
public void Dispose() { _optionsBuilder = null; // Cleanup any created database items. foreach (var BottleSize in _dbContext.BottleSizes) { _dbContext.BottleSizes.Remove(BottleSize); } _dbContext.SaveChanges( ); _dbContext.Dispose( ); _controller = null; }