Skip to content

Instantly share code, notes, and snippets.

@HEskandari
Created March 26, 2011 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HEskandari/888143 to your computer and use it in GitHub Desktop.
Save HEskandari/888143 to your computer and use it in GitHub Desktop.
Testing Saving of Decimal/Double Values
[Test]
public void Decimal_Values_Are_Not_Truncated_Once_Saved()
{
var entity = new DecimalEntity
{
SimpleDecimal = 1.1m,
SimpleDouble = 1.2d,
NullableDecimal = 1.3m,
NullableDouble = 1.4d
};
var session = SessionFactory.OpenSession();
session.Save(entity);
session.Flush();
session.Clear();
var readback = session.CreateCriteria(typeof(DecimalEntity))
.Add(Restrictions.Eq("Id", entity.Id))
.UniqueResult();
Assert.IsNotNull(entity);
Assert.AreEqual((decimal)1.1, entity.SimpleDecimal);
Assert.AreEqual(1.2, entity.SimpleDouble);
Assert.AreEqual((decimal?)1.3, entity.NullableDecimal);
Assert.AreEqual(1.4, entity.NullableDouble);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment