First, thank you everyone for all your help... I'm quickly getting NHibernate, but still have many questions. Currently I am writing some unit tests against a DAO, but in order for the test to succeed, I need to slip in a call to Flush() after setting up my data. Let me explain...
TEST(){
// #1 foolist = CreateFooList(5);
// #2 foolist[0].Active = false; foolist[1].Active = false;
// #3 activeFooList = GetActiveFoos();
// #4 Asserts
}
#1 My test begins by creating a number of Foo objects, and saving them.
#2 I then take a subset of the list of Foo objects and set the Active property to false.
#3 At this point, I have verified that 2 out of the 5 Foo objects have the Active property set to false. I then query to get all Active Foo objects via a NHibernate Criteria object.
#4 I assert that the length of activeFooList is 3 and that all items within the list have the Active property set to true. The problem is, activeFooList has a length of 5 and all items within the list have the Active property set to true, yet I expected two to have it set to False. Unless I make a call to Flush(); after setting the two Foo object to "inactive" this test fails. Since I am using one session during the entire scope of the test, I don't understand why I need the call to Flush(). Am I missing something?
Thanks! Bryan
|