Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22669/NHibernate.Test
Modified Files:
FooBarTest.cs FumTest.cs
Log Message:
Implemented more tests.
Index: FooBarTest.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** FooBarTest.cs 16 Jul 2004 03:58:10 -0000 1.47
--- FooBarTest.cs 28 Jul 2004 03:29:21 -0000 1.48
***************
*** 2667,2671 ****
[Test]
- //[Ignore("Test not written yet.")]
public void UserProvidedConnection()
{
--- 2667,2670 ----
***************
*** 2688,2712 ****
[Test]
- [Ignore("Test not written yet.")]
public void CachedCollection()
{
}
[Test]
- [Ignore("Test not written yet.")]
public void ComplicatedQuery()
{
}
[Test]
! [Ignore("Test not written yet.")]
public void LoadAfterDelete()
{
}
[Test]
- [Ignore("Test not written yet.")]
public void ObjectType()
{
}
--- 2687,2811 ----
[Test]
public void CachedCollection()
{
+ ISession s = sessions.OpenSession();
+ Baz baz = new Baz();
+ baz.SetDefaults();
+ s.Save(baz);
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ baz = (Baz)s.Load( typeof(Baz), baz.Code );
+ ( (FooComponent)baz.TopComponents[0]).Count = 99;
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ baz = (Baz)s.Load( typeof(Baz), baz.Code );
+ Assert.AreEqual( 99, ( (FooComponent)baz.TopComponents[0]).Count );
+ s.Delete(baz);
+ s.Flush();
+ s.Close();
+
}
[Test]
public void ComplicatedQuery()
{
+ ISession s = sessions.OpenSession();
+ Foo foo = new Foo();
+ object id = s.Save(foo);
+ Assert.IsNotNull(id);
+ Qux q = new Qux("q");
+ foo.Dependent.Qux = q;
+ s.Save(q);
+ q.Foo.String = "foo2";
+
+ IEnumerator enumer = s.Enumerable("from foo in class Foo where foo.Dependent.Qux.Foo.String = 'foo2'").GetEnumerator();
+ Assert.IsTrue( enumer.MoveNext() );
+ s.Delete(foo);
+ s.Flush();
+ s.Close();
}
[Test]
! [Ignore("Test depends on Proxies being implemented.")]
public void LoadAfterDelete()
{
+ ISession s = sessions.OpenSession();
+ Foo foo = new Foo();
+ object id = s.Save(foo);
+ s.Flush();
+ s.Delete(foo);
+
+ bool err = false;
+ try
+ {
+ s.Load( typeof(Foo), id );
+ }
+ catch(ObjectDeletedException ode)
+ {
+ err = true;
+ }
+ Assert.IsTrue(err);
+ s.Flush();
+ err = false;
+
+ try
+ {
+ bool somevalue = ( (FooProxy)s.Load( typeof(Foo), id )).Boolean;
+ }
+ // this won't work until Proxies are implemented because now it throws an
+ // ObjectNotFoundException
+ catch(LazyInitializationException lie)
+ {
+ err = true;
+ }
+ Assert.IsTrue(err);
+
+ Fo fo = Fo.NewFo();
+ id = FumTest.FumKey("abc"); //yuck!
+ s.Save(fo, id);
+ s.Flush();
+ s.Delete(fo);
+ err = false;
+
+ try
+ {
+ s.Load( typeof(Fo), id );
+ }
+ catch(ObjectDeletedException ode)
+ {
+ err = true;
+ }
+
+ Assert.IsTrue(err);
+ s.Close();
+
}
[Test]
public void ObjectType()
{
+ ISession s = sessions.OpenSession();
+ GlarchProxy g = new Glarch();
+ Foo foo = new Foo();
+ g.Any = foo;
+ object gid = s.Save(g);
+ object fid = s.Save(foo);
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ g = (GlarchProxy)s.Load( typeof(Glarch), gid );
+ Assert.IsNotNull( g.Any );
+ Assert.IsTrue( g.Any is FooProxy );
+ Assert.AreEqual( fid, ((FooProxy)g.Any).Key );
+ s.Delete(g.Any);
+ s.Delete(g);
+ s.Flush();
+ s.Close();
+
}
Index: FumTest.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FumTest.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** FumTest.cs 20 Jul 2004 13:58:55 -0000 1.8
--- FumTest.cs 28 Jul 2004 03:29:21 -0000 1.9
***************
*** 43,47 ****
}
! static FumCompositeID FumKey(String str)
{
--- 43,47 ----
}
! public static FumCompositeID FumKey(String str)
{
***************
*** 49,53 ****
}
! static FumCompositeID FumKey(String str, bool aCompositeQueryTest)
{
FumCompositeID id = new FumCompositeID();
--- 49,53 ----
}
! public static FumCompositeID FumKey(String str, bool aCompositeQueryTest)
{
FumCompositeID id = new FumCompositeID();
|