I figured out a hack to get it to work, but maybe there is a different way that I didn’t see.
My question is… what is the proper way to run the PostgreSql OrmLite individual tests ONLY, instead of using the below hacks? (using Resharper GUI, not command line)
I only need to test something quickly for a possible issue…
My quick and stupid hack to get it to work (b/c I didn’t have time to figure out what all setup was needed) is:
Start with a fresh git pull
Then load solution in Visual Studio.
Then execute a single test case or test fixture.
If you get the following error when running an already existing test like CustomSqlIssue.cs:
Dialect not included in TestConfig.Dialect value Sqlite
// OLD
public static Dialect Dialects = EnvironmentVariable("ORMLITE_DIALECT", Dialect.Sqlite);
// NEW
public static Dialect Dialects = EnvironmentVariable("ORMLITE_DIALECT", Dialect.AnyPostgreSql);
If you cannot connect and getting a connection refused or server timed out error (No connection could be made because the target machine actively refused it), please note that the connection string in the App.config gets overwritten.
Most notably the Port is overridden (if you use the same user/password).
To combat this (b/c I"m using ReSharper GUI) and as a quick fix (e.g. stupid, don’t commit this)…
In ServiceStack.OrmLite\OrmLiteConnectionFactory.cs in method CreateDbConnection() add the following line.
// https://github.com/ServiceStack/ServiceStack.OrmLite/blob/master/src/ServiceStack.OrmLite/OrmLiteConnectionFactory.cs#L67
this.ConnectionString = this.ConnectionString.Replace("Port=48301", "Port=5432");
this.ConnectionString = this.ConnectionString.Replace("Port=48302", "Port=5432");
this.ConnectionString = this.ConnectionString.Replace("Port=48303", "Port=5432");
// Note: Port 5432 is the default PostgreSql port.
If you now get a permission denied for user test then
-- using a superuser account
-- assumes db test is already created
GRANT ALL PRIVILEGES ON DATABASE test TO test;
Basically you need to specify which RDBMS dialect you want to run by setting:
Generally the only external setup I can recall is needing to create a Schema called “Schema” for RDBMS’s that support schemas, otherwise you just need to modify TestConfig above to specify which RDBMS + version you want to use.
If you pull the latest from OrmLite you will be able to run just your single version of PostgreSQL, e.g: