Thanks to a code contribution from an adopter of NDbUnit, I’m happy to announce that NDbUnit v1.6 is now released and available for download from the Google Code downloads page with support for Oracle 8i and later.
Oracle support has been on the project’s roadmap for some time now and its great to be able to introduce this support at long-last (and even more enjoyable to be able to jump-start this functionality with a contribution from an adopter of the project).
I’m happy to say that this now brings the complete list of supported DB targets under NDbUnit to six:
- Microsoft SQL Server (including Express Editions and on up to Enterprise)
- Microsoft OleDb-supported databases*
- Microsoft SqlServerCe/Mobile Edition/whatever its called this month
- MySql
- Oracle (including XE and on up to Enterprise)
- SqlLite (including both on-disk and in-memory variants)
*there is currently a known issue with OleDb support that is under review
FWIW, I’d still love to get support for PostGreSql in there too at some point (hint –hint, community!)
Proteus Unit Test Libraries update Released as well!
Now that NDbUnit properly supports Oracle, its possible to extend the Proteus Project’s Unit testing libraries to do the same and so I’m also happy to announce that the 1.2.6 release of the Proteus.UnitTest.dll library is also now available for download from its own Google Code downloads page. The Proteus utility classes that wrap NDbUnit with a series of convenience methods now also support Oracle as a database target.
Happy coding~!
Any chance for Firebird database support ???
Regards,
@Mocte:
Not really, but that’s a great idea. Would you be interested in submitting a patch for this as was just done for Oracle?
Else we would be glad to put it on the roadmap, but cannot predict when we’ll get to it (competing priorities, and all that).
-Steve B.
Steve,
I’m relatively new to .NET and altough I have done some apps with C#, actually I’m not doing .NET programming for my everyday work, just for the sake of learning, but I’m moving onto .NET and I would be very interested on collaborating with a FB patch for NDbunit because it is my database of choice, but first I would like to finish your summer of NH sessions and after it I’ll be glad to help.
Best regards,
Mocte
@Mocte:
That would be great — let me know if there’s anything I can do to assist you when you’re ready. Would be great to get firebird support added to NDbUnit!
-Steve B.
I have a SQL Server database and I am able to get Proteus to save the test database in my TestFixture setup but I can’t get it to work with SQLite. I am able to hit the SQLite database in my unit test but I can’t get Proteus to save the SQLite test database.
I have found connection strings for SQLite on the net that all contain “Version=3;New=boolean:” but I get an error when I add this to the connection string.
Any help would be greatly appreciated!
I get the following error.
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at NDbUnit.Core.DbCommandBuilder.GetSchemaTable(IDbCommand sqlSelectCommand)
at NDbUnit.Core.DbCommandBuilder.CreateSelectCommand(DataSet ds, String tableName)
NDbUnit.Core.NDbUnitException: DbCommandBuilder.CreateSelectCommand(DataSet, string) failed for tableName = ‘Customer’
at NDbUnit.Core.DbCommandBuilder.CreateSelectCommand(DataSet ds, String tableName)
at NDbUnit.Core.DbCommandBuilder.BuildCommands(Stream xmlSchema)
at NDbUnit.Core.NDbUnitTest.ReadXmlSchema(Stream xmlSchema)
at NDbUnit.Core.NDbUnitTest.ReadXmlSchema(String xmlSchemaFile)
at Proteus.Utility.UnitTest.DatabaseUnitTestBase.SaveDatabase(String connectionString, String schemaFilePathName, String datasetFilePathName, DatabaseClientType clientType)
at Proteus.Utility.UnitTest.DatabaseUnitTestBase.SaveTestDatabase()
at DataAccessLayerTestSqlite.NHibernateDataProviderTestSQLite.TestFixtureSetup() in Sqlite.cs: line 24
Here is the TestFixture
[TestFixture]
public class NHibernateDataProviderTestSQLite : Proteus.Utility.UnitTest.DatabaseUnitTestBase
{
[TestFixtureSetUp]
public void TestFixtureSetup()
{
SaveTestDatabase(); *****Line 24
DatabaseFixtureSetUp();
}
This is my APP.CONFIG
Here is my HIBERNATE.CFG.XML
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SQLite20Driver
data source=C:\WIP\DineAndDiscussNHibernate\TestDatabase\DineDiscuss.db3
NHibernate.Dialect.SQLiteDialect
true=1;false=0
true
oops
Here is my APP.CONFIG
@Lee M:
Your first clue is in the ‘meat’ of your exception message here:
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
Note that the error is coming from “System.Data.SqlClient” which indicates that the Proteus classes are thinking they should be using the SQLServer ADO.NET infrastructure instead of the SQLite ADO.NET infrastructure.
In addition to changing the connection strings, et. al. you also must tell the Proteus.Utility.UnitTest.DatabaseUnitTestBase class to use the Sqlite-specific infrastructure to talk to the database.
If you look at line 122 of the source code here… http://code.google.com/p/proteusproject/source/browse/trunk/src/Proteus.Utility.UnitTest/DatabaseUnitTestBase.cs#122 …you can see that the _databaseClientType field in the base class is set by default to the enum DatabaseClientType.SqlClient. To use Proteus with other database targets supported by NDbUnit, you also need to change this enum value in your derived class (probably in the [TestFixtureSetUp] method is safest as in …
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
_databaseClientType = DatabaseClientType.SqliteClient;
DatabaseFixtureSetUp();
//rest of your code here as needed
}
After that, I believe it should work for you. Let me know how you make out with it.
-Steve B.
Thanks for the quick reply. I then had an error that the version of System.Data.SQLite was not 1.0.60. I had downloaded the 1.0.65 version, so I got the correct version and that got me farther. I then got this error
System.InvalidOperationException: Unsupported Database client type: SqliteClient
at Proteus.Utility.UnitTest.DatabaseUnitTestBase.ValidateSchemaAgainstDatabase(String schemaFilename)
at Proteus.Utility.UnitTest.DatabaseUnitTestBase.DatabaseFixtureSetUp(Boolean ignoreSchemaDifferences)
at Proteus.Utility.UnitTest.DatabaseUnitTestBase.DatabaseFixtureSetUp()
at DataAccessLayerTestSqlite.NHibernateDataProviderTestSQLite.TestFixtureSetup() in
I then passed “true” to the DatabaseFixtureSetUp, and it worked beautifully
[TestFixtureSetUp]
public void TestFixtureSetup()
{
_databaseClientType = DatabaseClientType.SqliteClient;
SaveTestDatabase();
DatabaseFixtureSetUp(true);
}
Thank you for the help and the videos, I am working my way through Summer on NHibernate and then it will be on to Autumn of Agile. These videos are very well done and chock full of valuable information. Thanks again!!
@Lee M:
Interesting — I had forgotten that part (the boolean flag to skip DB + XSD comparison for targets that don’t support it!). That’s the result of a recent refactoring to support different validator logic for different DB targets and — indeed — SQLite isn’t supported for runtime DB < --> XSD validation as of yet.
Glad you got it working — and thx for the comments re: the screencasts~!
-Steve B.
Hi Steve
Just wanted to thank you for this , it has saved us a lot of time already
As quick background we have layered a simple set of datatable comparisons on top of your libary ( all based on XML so we have a schema file and then a series of xml files that highlight the outputs of the tests via nunit TestCases and linq.
In your opinion, how easy would it be to change the xml seed to be an array of seed files vs. a single file. we are looking at how we can best reuse our seed data sets for aggregates so we can compose them together to better exercise our domain, vs. having a custom seed for every set of tests ( typically the aggregates are the same and we compose them for each test case ). We tried but as some of the code in the LoadDatabase is private so we would have to basically implement the whole library vs. just overloading explictly what we need.
We also are looking at being able to disable the creation the backups.
The last thing we have to do is to be able to create a data table of the output parameters / rc from the ado command object so we can compare those as well if necessary.
Excellent work, look forward to your thoughts.