Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dsibinski
Created July 27, 2017 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsibinski/f8cbd51dbfb33ef360e16d1d56e164e1 to your computer and use it in GitHub Desktop.
Save dsibinski/f8cbd51dbfb33ef360e16d1d56e164e1 to your computer and use it in GitHub Desktop.
[TestClass]
public class CarServiceContextInitTests
{
// to have the same Configuration object as in Startup
private IConfigurationRoot _configuration;
// represents database's configuration
private DbContextOptions<CarServiceContext> _options;
public CarServiceContextInitTests()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
_configuration = builder.Build();
_options = new DbContextOptionsBuilder<CarServiceContext>()
.UseSqlServer(_configuration.GetConnectionString("DefaultConnection"))
.Options;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment