public void CreateDbContextWhenGoodMySql() { var testDbContext = EntityFrameworkTools <MySqlDbContext> .CreateDbContext("", DEVELOPMENT_ENVIRONMENT); testDbContext.ShouldNotBeNull(); testDbContext.Cities.ShouldNotBeNull(); testDbContext.Countries.ShouldNotBeNull(); }
public void CreateDbContextWhenGoodMySqlInGenericSettingsFile() { var testDbContext = EntityFrameworkTools <MySqlDbContext> .CreateDbContext(); testDbContext.ShouldNotBeNull(); testDbContext.Cities.ShouldNotBeNull(); testDbContext.Countries.ShouldNotBeNull(); }
public void CreateDbContextWhenRepositoryAndConnectionStringWithAdminPrefixAreGoodInSettingsFile() { var testDbContext = EntityFrameworkTools <GoodDbContext_Development> .CreateDbContext("Admin_", DEVELOPMENT_ENVIRONMENT); testDbContext.ShouldNotBeNull(); testDbContext.Cities.ShouldNotBeNull(); testDbContext.Countries.ShouldNotBeNull(); }
public void CreateDbContextWhenOtherGoodEnvironmentAndSettingsFileExist() { var testDbContext = EntityFrameworkTools <GoodDbContext_Staging> .CreateDbContext("", STAGING_ENVIRONMENT); testDbContext.ShouldNotBeNull(); testDbContext.Cities.ShouldNotBeNull(); testDbContext.Countries.ShouldNotBeNull(); }
public void DontGetDbContextWhenDataBaseDontExist() { CreateServices(); EntityFrameworkTools <InMemoryDbContext> .AddDbContext(Services, Configuration); var provider = Services.BuildServiceProvider(); var dbContext = provider.GetService <NoConnectionStringForThisDbContext>(); dbContext.ShouldBeNull(); }
public void GetDbContextWithNoCityWhenDataBaseExistAndCitiesNoFilled() { CreateServices(); EntityFrameworkTools <GoodDbContext_Development> .AddDbContext(Services, Configuration); var provider = Services.BuildServiceProvider(); var dbContext = provider.GetService <GoodDbContext_Development>(); dbContext.ShouldNotBeNull(); dbContext.Cities.ShouldNotBeNull(); dbContext.Cities.ToList().Count.ShouldBe(0); }
public void GetDbContextWhenInMemory() { CreateServices(); EntityFrameworkTools <InMemoryDbContext> .AddDbContext(Services, Configuration); var provider = Services.BuildServiceProvider(); var dbContext = provider.GetService <InMemoryDbContext>(); dbContext.ShouldNotBeNull(); dbContext.Cities.ShouldNotBeNull(); dbContext.Countries.ShouldNotBeNull(); }
public void GetDbContextWith1ContryWhenDataBaseExistAnd1ContryAdd() { CreateServices(); EntityFrameworkTools <GoodDbContext_Development> .AddDbContext(Services, Configuration); var provider = Services.BuildServiceProvider(); var dbContext = provider.GetService <GoodDbContext_Development>(); dbContext.ShouldNotBeNull(); AddContryToDatabase(dbContext); dbContext.Countries.ShouldNotBeNull(); var countries = dbContext.Countries.ToList(); countries.Count.ShouldBe(1); countries[0].Name.ShouldBe(TestCountryName); countries[0].IsDemocracy.ShouldBeFalse(); }
public GoodDbContext_Development CreateDbContext(string[] args) => EntityFrameworkTools <GoodDbContext_Development> .CreateDbContext();
public GoodDbContext_Staging CreateDbContext(string[] args) => EntityFrameworkTools <GoodDbContext_Staging> .CreateDbContext();
public void ThrowWhenRepositoryPrefixAreBadInSettingsFile() { Should.Throw <ConnectionStringException>(() => EntityFrameworkTools <GoodDbContext_Development> .CreateDbContext("BadPrefix_", DEVELOPMENT_ENVIRONMENT)); }
public void ThrowConnectionStringException() { Should.Throw <ConnectionStringException>(() => EntityFrameworkTools <NoConnectionStringForThisDbContext> .CreateDbContext("", DEVELOPMENT_ENVIRONMENT)); }
public void ThrowRepositoryProviderExceptionWhenRepositoryAreBadInSettingsFile() { Should.Throw <RepositoryProviderException>(() => EntityFrameworkTools <BadProviderDbContext> .CreateDbContext("", DEVELOPMENT_ENVIRONMENT)); }
public void ThrowConnectionStringExceptionWhenEnvironmentIsBad() { Should.Throw <FileNotFoundException>(() => EntityFrameworkTools <GoodDbContextBase> .CreateDbContext("", "UnknowEnvironement")); }
public void ThrowConnectionStringExceptionWhenInMemory() { Should.Throw <ConnectionStringException>(() => EntityFrameworkTools <InMemoryDbContext> .CreateDbContext("", DEVELOPMENT_ENVIRONMENT)); }