From: Kevin W. <kev...@us...> - 2005-01-01 14:20:36
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/DriverTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11094 Added Files: NullReferenceFixture.cs Log Message: added test for NH-177 --- NEW FILE: NullReferenceFixture.cs --- using System; using System.Collections; using NUnit.Framework; namespace NHibernate.Test.DriverTest { /// <summary> /// http://jira.nhibernate.org/browse/NH-177 /// </summary> [TestFixture] public class NullReferenceFixture : TestCase { [SetUp] public void Setup() { ExportSchema( new string[] { "Simple.hbm.xml"} ); } /// <summary> /// No value is assigned for the given named parameter /// </summary> /// <remarks> /// Was giving a NullReferenceException in NHibernate.Driver.DriverBase.GenerateParameter /// at the line "dbParam.DbType = parameter.SqlType.DbType;" because "parameter" existed /// but all properties were null. /// </remarks> [Test] public void NoParameterNameNullReference() { ISession s = null; try { s = sessions.OpenSession(); Console.WriteLine( "about to run query" ); IQuery q = s.CreateQuery( "from Simple s where s.Name = :missing" ); Assert.IsNotNull( q ); q.List(); } catch( ADOException ae ) { Assert.IsTrue( ae.InnerException is QueryException ); Assert.IsTrue( ae.InnerException.Message.StartsWith( "No value assigned to parameter" ) ); } catch( Exception e ) { Console.WriteLine( e.ToString() ); throw; } finally { s.Close(); } } /// <summary> /// query succeeds when the parameter is assigned a value /// </summary> [Test] public void NamedParameterAssignedNoError() { ISession s = null; try { s = sessions.OpenSession(); Console.WriteLine( "about to run query" ); IQuery q = s.CreateQuery( "from Simple s where s.Name = :missing" ); Assert.IsNotNull( q ); q.SetString( "missing", "nhibernate" ); IList list = q.List(); Assert.IsNotNull( list ); } catch( Exception e ) { Console.WriteLine( e.ToString() ); throw; } finally { s.Close(); } } } } |