Commit b466cd6a authored by Marc Gravell's avatar Marc Gravell

Make Postgresql tests skip cleanly rather than error if no server

parent a4bb66de
......@@ -3218,12 +3218,11 @@ class Cat
new Cat() { Breed = "Persian", Name="MAGNA"}
};
[Fact]
[FactPostgresqlAttribute]
public void TestPostgresqlArrayParameters()
{
using (var conn = new NpgsqlConnection("Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest")) // ;Encoding=UNICODE
using (var conn = OpenPostgresqlConnection())
{
conn.Open();
IDbTransaction transaction = conn.BeginTransaction();
conn.Execute("create table tcat ( id serial not null, breed character varying(20) not null, name character varying (20) not null);");
conn.Execute("insert into tcat(breed, name) values(:breed, :name) ", Cats);
......@@ -3236,6 +3235,32 @@ public void TestPostgresqlArrayParameters()
transaction.Rollback();
}
}
static NpgsqlConnection OpenPostgresqlConnection()
{
var conn = new NpgsqlConnection("Server=localhost;Port=5432;User Id=dappertest;Password=dapperpass;Database=dappertest"); // ;Encoding=UNICODE
conn.Open();
return conn;
}
public class FactPostgresqlAttribute : FactAttribute
{
public override string Skip
{
get { return unavailable ?? base.Skip; }
set { base.Skip = value; }
}
private static string unavailable;
static FactPostgresqlAttribute()
{
try
{
using (OpenPostgresqlConnection()) { }
}
catch (Exception ex)
{
unavailable = $"Postgresql is unavailable: {ex.Message}";
}
}
}
#endif
}
}
......@@ -78,7 +78,8 @@
"MASSIVE",
"ORMLITE",
"SOMA",
"SIMPLEDATA"
"SIMPLEDATA",
"XUNIT2"
]
},
"frameworkAssemblies": {
......@@ -139,7 +140,8 @@
"MASSIVE",
"ORMLITE",
"SOMA",
"SIMPLEDATA"
"SIMPLEDATA",
"XUNIT2"
]
},
"frameworkAssemblies": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment