Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27938/nhibernate/src/NHibernate.Test/NHSpecificTest
Added Files:
CollectionFixture.cs SimpleFooBarFixture.cs
Log Message:
Simpler tests used when porting from 2.1 - easier to see the execution flow when debugging
--- NEW FILE: CollectionFixture.cs ---
using System;
using NHibernate.DomainModel.NHSpecific;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest
{
/// <summary>
/// Tests loading of collections very simply.
/// </summary>
[TestFixture]
public class CollectionFixture : TestCase
{
[SetUp]
public void SetUp()
{
ExportSchema( new string[] { "NHSpecific.LazyLoadBug.hbm.xml"} );
}
[Test]
public void TestLoadParentFirst()
{
int parentId = 0;
using( ISession s1 = sessions.OpenSession() )
using( ITransaction t1 = s1.BeginTransaction() )
{
// create a new
LLParent parent = new LLParent();
LLChildNoAdd child = new LLChildNoAdd();
parent.ChildrenNoAdd.Add( child );
child.Parent = parent;
s1.Save( parent );
parentId = (int)s1.GetIdentifier( parent );
t1.Commit();
}
// try to Load the object to make sure the save worked
using( ISession s2 = sessions.OpenSession() )
using( ITransaction t2 = s2.BeginTransaction() )
{
LLParent parent2 = (LLParent)s2.Load( typeof( LLParent ), parentId );
Assert.AreEqual( 1, parent2.ChildrenNoAdd.Count );
}
}
[Test]
public void TestLoadChildFirst()
{
int parentId = 0;
int childId = 0;
using( ISession s1 = sessions.OpenSession() )
using( ITransaction t1 = s1.BeginTransaction() )
{
// create a new
LLParent parent = new LLParent();
LLChildNoAdd child = new LLChildNoAdd();
parent.ChildrenNoAdd.Add( child );
child.Parent = parent;
s1.Save( parent );
parentId = (int)s1.GetIdentifier( parent );
childId = (int)s1.GetIdentifier( child );
t1.Commit();
}
// try to Load the object to make sure the save worked
using( ISession s2 = sessions.OpenSession() )
using( ITransaction t2 = s2.BeginTransaction() )
{
LLChildNoAdd child2 = (LLChildNoAdd)s2.Load( typeof( LLChildNoAdd ), childId );
Assert.AreEqual( parentId, (int)s2.GetIdentifier( child2.Parent ) );
}
}
}
}
--- NEW FILE: SimpleFooBarFixture.cs ---
using System;
using System.Data;
using NHibernate.DomainModel;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest
{
[TestFixture]
public class SimpleFooBarFixture : TestCase
{
[SetUp]
public void SetUp()
{
ExportSchema( new string[] { "FooBar.hbm.xml"} );
}
}
}
|