Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31376/SqlCommandTest
Added Files:
SqlStringBuilderFixture.cs SqlStringFixture.cs
Log Message:
Added tests for new functionallity with SqlStrings.
--- NEW FILE: SqlStringBuilderFixture.cs ---
using System;
using NHibernate.SqlCommand;
using NUnit.Framework;
namespace NHibernate.Test.SqlCommandTest
{
/// <summary>
/// Summary description for SqlStringBuilderFixture.
/// </summary>
[TestFixture]
public class SqlStringBuilderFixture
{
[Test]
public void InsertAndAdd()
{
SqlStringBuilder builder = new SqlStringBuilder();
builder.Add("col1, col2 ");
builder.Insert( 0, "select ");
builder.Add("from table ");
Assert.AreEqual( "select col1, col2 from table ", builder.ToSqlString().ToString() );
}
}
}
--- NEW FILE: SqlStringFixture.cs ---
using System;
using NHibernate.SqlCommand;
using NUnit.Framework;
namespace NHibernate.Test.SqlCommandTest
{
/// <summary>
/// Summary description for SqlStringFixture.
/// </summary>
[TestFixture]
public class SqlStringFixture
{
[Test]
public void Append()
{
SqlString sql = new SqlString( new string[] { "select", " from table" } );
SqlString postAppendSql = sql.Append(" where A=B" );
Assert.IsFalse( sql==postAppendSql, "should be a new object" );
Assert.AreEqual( 3, postAppendSql.SqlParts.Length );
sql = postAppendSql;
postAppendSql = sql.Append( new SqlString(" and C=D") );
Assert.AreEqual(4, postAppendSql.SqlParts.Length );
Assert.AreEqual( "select from table where A=B and C=D", postAppendSql.ToString() );
}
}
}
|