public void UseNpgsql_ThrowsIfServiceNameNull() { var optionsBuilder = new DbContextOptionsBuilder(); var goodBuilder = new DbContextOptionsBuilder <GoodDbContext>(); var config = new ConfigurationBuilder().Build(); string serviceName = null; var ex2 = Assert.Throws <ArgumentException>(() => PostgresDbContextOptionsExtensions.UseNpgsql(optionsBuilder, config, serviceName)); Assert.Contains(nameof(serviceName), ex2.Message); var ex4 = Assert.Throws <ArgumentException>(() => PostgresDbContextOptionsExtensions.UseNpgsql <GoodDbContext>(goodBuilder, config, serviceName)); Assert.Contains(nameof(serviceName), ex4.Message); }
public void UseNpgsql_ThrowsIfConfigurationNull() { var optionsBuilder = new DbContextOptionsBuilder(); var goodBuilder = new DbContextOptionsBuilder <GoodDbContext>(); IConfigurationRoot config = null; var ex = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql(optionsBuilder, config)); Assert.Contains(nameof(config), ex.Message); var ex2 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql(optionsBuilder, config, "foobar")); Assert.Contains(nameof(config), ex2.Message); var ex3 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql <GoodDbContext>(goodBuilder, config)); Assert.Contains(nameof(config), ex3.Message); var ex4 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql <GoodDbContext>(goodBuilder, config, "foobar")); Assert.Contains(nameof(config), ex4.Message); }
public void UseNpgsql_ThrowsIfDbContextOptionsBuilderNull() { // Arrange DbContextOptionsBuilder optionsBuilder = null; DbContextOptionsBuilder <GoodDbContext> goodBuilder = null; IConfigurationRoot config = null; // Act and Assert var ex = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql(optionsBuilder, config)); Assert.Contains(nameof(optionsBuilder), ex.Message); var ex2 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql(optionsBuilder, config, "foobar")); Assert.Contains(nameof(optionsBuilder), ex2.Message); var ex3 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql <GoodDbContext>(goodBuilder, config)); Assert.Contains(nameof(optionsBuilder), ex3.Message); var ex4 = Assert.Throws <ArgumentNullException>(() => PostgresDbContextOptionsExtensions.UseNpgsql <GoodDbContext>(goodBuilder, config, "foobar")); Assert.Contains(nameof(optionsBuilder), ex4.Message); }