I'm using nunit to test out my activerecord models and make sure my
mapping works as expected. Strangely, I'm getting an error every once
in a while when running my tests:
System.Data.SqlClient.SqlException: The INSERT statement conflicted
with the FOREIGN KEY constraint "FK618CE2931513F4CD". The conflict
occurred in database "TestDatabase", table "dbo.Team", column 'Id'.
The statement has been terminated.
I'll run a test once, get this error. If I run it again, I may or may
not get the same error. Sometimes it goes through fine, sometimes it
does not. It's driving me crazy.
All of my test classes inherit from this:
public class ActiveRecordSetupFixture : BaseControllerTest
{
private static bool _alreadySetup = false;
private static SessionScope _scope;
//The test's [TestFixtureSetUp] will call this method
protected void Setup()
{
SetupActiveRecord();
}
private static void SetupActiveRecord()
{
if (!_alreadySetup)
{
log4net.Config.XmlConfigurator.Configure();
ActiveRecordStarter.Initialize(typeof
(ModelBase<>).Assembly, ActiveRecordSectionHandler.Instance);
_alreadySetup = true;
ActiveRecordStarter.DropSchema();
ActiveRecordStarter.CreateSchema();
}
_scope = new SessionScope(FlushAction.Auto);
}
}
Any ideas if I'm doing something wrong with my test setup, or if it's
something in my mapping? If it's a mapping problem, why does it only
happen sometimes?
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=.