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