Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10798/src/Nullables.Tests
Modified Files:
Nullables.Tests-1.1.csproj
Added Files:
NullableCharFixture.cs
Log Message:
Added NullableChar
--- NEW FILE: NullableCharFixture.cs ---
using System;
using Nullables;
using NUnit.Framework;
namespace Nullables.Tests
{
/// <summary>
/// Summary description for NullableCharFixture.
/// </summary>
[TestFixture]
public class NullableCharFixture
{
[Test]
public void BasicTestChar()
{
NullableChar v1 = 'd'; //chould take a char literal
Assert.IsTrue( v1.HasValue ); //should have a value;
Assert.IsTrue( v1.Equals( 'd' ) ); //implicit casting should make this result in true.
Assert.IsTrue( v1.Value == 'd' );
Assert.IsFalse( v1.Equals( NullableChar.Default ) );
Assert.IsTrue( v1.Equals( new NullableChar( 'd' ) ) ); //should == a new instance with the same inner value.
//same thing, but with == instead of .Equals()
Assert.IsTrue( v1 == 'd' );
Assert.IsFalse( v1 == 'g' );
Assert.IsFalse( v1 == NullableChar.Default );
Assert.IsTrue( v1 == new NullableChar( 'd' ) );
//now null v1.
v1 = DBNull.Value;
Assert.IsTrue( v1 == NullableChar.Default );
v1 = NullableChar.Default;
Assert.IsTrue( v1 == NullableChar.Default );
NullableChar v2 = NullableChar.Default; //should start as "null"
Assert.IsFalse( v2.HasValue );
Assert.IsFalse( v2.Equals( '2' ) );
Assert.IsTrue( v2.Equals( NullableChar.Default ) );
Assert.IsTrue( v2.Equals( DBNull.Value ) );
}
[Test, ExpectedException(typeof(InvalidOperationException))]
public void CharMissingValueTest()
{
NullableChar x = NullableChar.Default;
Char y = x.Value;
}
[Test]
public void CharIComparableTest()
{
NullableChar x;
NullableChar y;
//one null, one not
x = NullableChar.Default;
y = new NullableChar( 'y' );
Assert.IsTrue( x.CompareTo( y ) < 0 );
Assert.IsTrue( y.CompareTo( x ) > 0 );
//now both null
x = NullableChar.Default;
y = NullableChar.Default;
Assert.IsTrue( x.CompareTo( y ) == 0 );
Assert.IsTrue( y.CompareTo( x ) == 0 );
//now both with a value
x = new NullableChar( 'a' );
y = new NullableChar( 'u' );
Assert.IsTrue( x.CompareTo( y ) < 0 );
Assert.IsTrue( y.CompareTo( x ) > 0 );
}
}
}
Index: Nullables.Tests-1.1.csproj
===================================================================
RCS file: /cvsroot/nhibernate/NHibernateContrib/src/Nullables.Tests/Nullables.Tests-1.1.csproj,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Nullables.Tests-1.1.csproj 16 Dec 2004 15:26:13 -0000 1.3
--- Nullables.Tests-1.1.csproj 28 Apr 2005 18:51:38 -0000 1.4
***************
*** 129,132 ****
--- 129,137 ----
/>
<File
+ RelPath = "NullableCharFixture.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "NullableDateTimeFixture.cs"
SubType = "Code"
|