Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv30261
Modified Files:
SessionScopeTests.cs
Log Message:
SPRNET-785 - SessionScope / OSIV should obtain 1 EntityInterceptor per Session instance
Index: SessionScopeTests.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Data.NHibernate.Tests/Data/NHibernate/Support/SessionScopeTests.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SessionScopeTests.cs 21 Mar 2008 01:17:12 -0000 1.3
--- SessionScopeTests.cs 24 Apr 2008 21:32:07 -0000 1.4
***************
*** 2,6 ****
/*
! * Copyright © 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
--- 2,6 ----
/*
! * Copyright © 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
***************
*** 32,36 ****
{
/// <summary>
! ///
/// </summary>
/// <author>Erich Eichinger</author>
--- 32,36 ----
{
/// <summary>
! /// Tests for SessionScope
/// </summary>
/// <author>Erich Eichinger</author>
***************
*** 74,77 ****
--- 74,108 ----
[Test]
+ public void CanCreateAndCloseSimpleCtor()
+ {
+ using (repository.Ordered())
+ {
+ ISession session = (ISession) repository.CreateMock(typeof (ISession));
+ Expect.Call(expectedSessionFactory.OpenSession()).Return(session);
+ session.FlushMode = FlushMode.Never;
+ Expect.Call(session.Close()).Return(null);
+ }
+ repository.ReplayAll();
+ using (SessionScope scope = new SessionScope(expectedSessionFactory, true))
+ {
+ // no op - just create & dispose
+ Assert.AreSame(expectedSessionFactory, scope.SessionFactory);
+ //Assert.AreSame(null, scope.EntityInterceptor);
+ Assert.AreEqual(expectedSingleSession, scope.SingleSession);
+ Assert.AreEqual(expectedDefaultFlushMode, scope.DefaultFlushMode);
+
+ // ensure SessionHolder object is registered with TSM
+ Assert.IsTrue(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
+
+ SessionHolder sessionHolder =
+ (SessionHolder) TransactionSynchronizationManager.GetResource(expectedSessionFactory);
+ // by default session is lazy, so ask for it.
+ Assert.IsNotNull(sessionHolder.Session);
+ scope.Close();
+ }
+ repository.VerifyAll();
+ }
+
+ [Test]
[ExpectedException(typeof(InvalidOperationException))]
public void OpeningTwiceThrowsInvalidOperationException()
|