Why not have nhibernate regenerate the schema for every unit test.
Now you've got total isolation because the entire schema is dropped after every test.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/02Ts1K8I4YsJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
+1, if you're reusing the database between fixture runs your tests can quickly become non-deterministic.To speed things up for you, is SqlLite in-memory an option for your scenario?On 8 June 2012 23:33, Fran Knebels <fkne...@gmail.com> wrote:
Why not have nhibernate regenerate the schema for every unit test.
Now you've got total isolation because the entire schema is dropped after every test.
On Jun 8, 2012 5:51 PM, "SirSirAaron" <theyell...@gmail.com> wrote:
Thanks for the super quick reply Jason. I think you may be right regarding the time at which nhibernate increments the "hi". I understand the basics of hilo generation and the necessity for a table to store the "hi" for synchronization across multiple session factories. That being said, I understand what I'm doing is contrary to its design and I'm purposefully looking for a hack or another way of approaching the problem.At the moment I am using fluent nhibernate's persistencespecification tests for each of my domain objects which will eventually grow to hundred or so tests. Additionally, I create a new session factory for each test in an effort to achieve isolation. I have multiple developers running these tests daily and I would prefer not to increment the "hi".Right now I have a max_lo = 100(2^31[size of int])/100[max_lo]/100[number of unit tests] = 214 748Lets say I have 50 developers running these tests 10 times a day then I'll be out of space after a year so:(2^31-1)/100/100/50[developers]/10[number of times test run]/365 = 1.17
--
On Friday, June 8, 2012 5:02:49 PM UTC-4, Jason Meckley wrote:IIRC hi is created the first time the entity is requested, not when the factory is created. in a unit test this could occur at the same time. In either case the high value must be created. it's stored in the db to ensure uniqueness. without this there is a potential for duplicate keys. NH protects the dev from this. What you described is by design and not meant to be altered. NH is meant to touch a DB. if you don't want to touch a physical db use a sqlite in-memory db. they are lighting fast compared to a file DB.
On Friday, June 8, 2012 3:35:11 PM UTC-4, SirSirAaron wrote:When I am running unit tests I don't want increment the hi when a session factory is created. Does anyone know a way in which to prevent this behavior? Additionally, it would be great if I could set the session factory's hi manually without touching the database.
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/02Ts1K8I4YsJ.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.