Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31543/NHibernate.Test
Modified Files:
FooBarTest.cs
Log Message:
NH-143: QueryImpl can now guess type correctly when passing an enum
into SetParamater(..., value)
Index: FooBarTest.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v
retrieving revision 1.69
retrieving revision 1.70
diff -C2 -d -r1.69 -r1.70
*** FooBarTest.cs 3 Nov 2004 03:37:05 -0000 1.69
--- FooBarTest.cs 4 Nov 2004 04:46:12 -0000 1.70
***************
*** 2377,2380 ****
--- 2377,2407 ----
foo = (FooProxy)s.Load( typeof(Foo), id);
Assert.AreEqual( FooStatus.OFF, foo.Status );
+ s.Close();
+
+ // verify that SetEnum with named params works correctly
+ s = sessions.OpenSession();
+ IQuery q = s.CreateQuery( "from Foo as f where f.Status = :status" );
+ q.SetEnum( "status", FooStatus.OFF );
+ IList results = q.List();
+ Assert.AreEqual( 1, results.Count, "should have found 1" );
+ foo = (Foo)results[0];
+
+ q = s.CreateQuery( "from Foo as f where f.Status = :status" );
+ q.SetEnum( "status", FooStatus.ON );
+ results = q.List();
+ Assert.AreEqual( 0, results.Count, "no foo with status of ON" );
+
+ // try to have the Query guess the enum type
+ q = s.CreateQuery( "from Foo as f where f.Status = :status" );
+ q.SetParameter( "status", FooStatus.OFF );
+ results = q.List();
+ Assert.AreEqual( 1, results.Count, "found the 1 result" );
+
+ // have the query guess the enum type in a ParameterList.
+ q = s.CreateQuery( "from Foo as f where f.Status in (:status)" );
+ q.SetParameterList( "status", new FooStatus[] { FooStatus.OFF, FooStatus.ON } );
+ results = q.List();
+ Assert.AreEqual( 1, results.Count, "should have found the 1 foo" );
+
s.Delete(foo);
s.Flush();
|