NUnit and the app.config
By David Givoni
This entry was posted on 8 December, 2005 at 12:55 am and is filed under .NET (C#), O/R Mapping, Test Driven Development (TDD). You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
8 December, 2005 at 3:30 am
Hi David, great to see a new blog pop up – especially one touching on O/R Mapping.
I’ve been experimenting with nHibernate lately and quite enjoying it – it seems like it needs a bit better community around it (it gets drowned out by the hibernate folks!
)
This is mostly just a “pop in to say hi” message. I look forward to seeing your future entries.
– JD
8 December, 2005 at 11:41 am
Hi John-Daniel,
I’m surprised, but glad to see that someone already found the blog, since I haven’t done anything to “show it off” yet, hehe.
Thanks for the message, I just had a look at your own blog and it seems very interesting, I’ll take a deeper look later today.
/David
8 December, 2005 at 11:51 am
Ok, I just had a look at the referrers (stilll getting to know the wordpress engine) and found out that my friend Tim Haines posted a notice about me going online. Now I understand where you came from, John-Daniel.
Thanks, Tim
8 December, 2005 at 9:43 pm
David,
Any comments on building your NHibernate config files? I’ve tried the Matsoft tool, but while it was good, doing M-N relationships was, well, fun…
Any thoughts on things to use? or examples of each kind of relationship (1-1, 1-N, M-N, M-1 etc)
Cheers
Nic
10 December, 2005 at 1:25 am
Hi Nic,
I tried Matsoft too, but got exception-errors several times and gave it up.
Instead I have tried CodeSmith and MyGeneration. I’m about to write a small entry on it now. Both worked ok for me.
Cheers,
David
10 December, 2005 at 2:31 am
[...] Inspired by Nic Wise’s question regarding how I generate the mapping files for NHibernate, I wanted to write a bit about my experience with automatic code generation tools and O/R Mappers. This is not a discussion of O/R Mappers versus automatic code generation, but my own experience on how to combine the two. [...]
17 December, 2005 at 12:46 am
Just wanted to say thanks for publishing the solution. I ran into this problem today and tried all sorts of things(app.config,hibernate.cfg.xml, myapp.dll.config) to get to work. Now’s it’s working fine that’s to you. It took me awhile but now that I’ve got nhibernate up and running it’s sure worth the effort.
19 December, 2005 at 5:09 am
One of the things I tell folks to do when using NUnit is to add a prebuild event to their Test Project (if it is a dll) that contains the following command: copy /Y “$(ProjectDir)app.config” “$(TargetPath).config”
This way, every time you do a build, it will copy over the app.config file, and rename it for you. Unfortunately, in VS 2003, pre and post build events are only available to C# projects. To accomplish the same thing using VB, you have to download some additional VS extensions and even then, the build events are in the solution file, not the project file. This has been fixed in VS 2005.
19 December, 2005 at 10:01 am
Yes, Don, I actually also had a build-event to do this automatically.
But this didn’t work in my case.
It only works in the first case, as far as I found out, that is if you didn’t create a project in NUnit, but just load the dll to test.
13 February, 2006 at 8:53 am
I am curious to know why you selected SQLite and how you found it (speed, any bugs, easy to work with etc)
5 May, 2006 at 11:18 am
Hi Cris,
Sorry I’ve been so late at responding to this, I simply forgot and havent been able to blog much lately.
Anyway to answer your questions, what I needed was a database to be able to distribute with the application without having to install anything “extra” on the client machine that was using the application. It’s a non-internet based windows application.
I found SQLLite to be a bit difficult to use. Let me say though that my experience was from november/december 2005, so it might be slightly out of date.
First of all the only interface is text-based, so the whole database structure has to be created with sql statements. This just takes longer time than with a visual based application as visual studio.net. And reviewing information int the database is the same way. What is a bigger problem though, is that it doesn’t support the “ALTER TABLE” statement, so every time you have to change the structure of a table, you have to delete it and create it again. Also there are no relationship contraints, so you have to be very sure that you don’t create inconsistent data!
I was considering using MS Access at first, but at that moment the support for it in NHibernate was pretty bad, now it’s better though. I also looked at Firebird, but that requires a separate installation of the database.
I think at this moment I would go for Access if I had to choose again although there is the issue with licensing that has to be considered as well.
Hope this answers your question, and again sorry for having forgotten to answer before.
/David
31 May, 2006 at 12:29 pm
Hi David,
I’m newbie about NHibernate and NUnit. Do you know how debug NUnit test on NHibernate? I get an example from internet and I try to run with NUnit. I use your suggest about .config and it works. But on a test I get a fail, I dont know why and I would debug them. I use VS 2003.
31 May, 2006 at 1:03 pm
Hi Antonio,
I’m glad my suggestion worked for you too.
In order to help you with your problem, could you post your test code and give some more details on what goes wrong?
/David
24 September, 2006 at 11:01 pm
Hi David,
I just ran into similar problem. By looking at your blog entry I solved the problem very quickly. Also I found out that you do not need to name your config file NUnitProjectName.config, that is you can change it by following Project/Edit… menu option, and then at General tab you can change Configuration File Name property to any config file you want.
Off to solving other problems
Mihailo
27 September, 2006 at 4:10 pm
Thanks for the solution to this problem!
–
Greg
11 October, 2006 at 5:55 pm
[...] Inspired by Nic Wise’s question regarding how I generate the mapping files for NHibernate, I wanted to write a bit about my experience with automatic code generation tools and O/R Mappers. This is not a discussion of O/R Mappers versus automatic code generation, but my own experience on how to combine the two. [...]