Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Created May 19, 2009 17:31
Show Gist options
  • Save drmohundro/114244 to your computer and use it in GitHub Desktop.
Save drmohundro/114244 to your computer and use it in GitHub Desktop.
Unit test to go along with Fluent NHibernate version of InMemoryDatabaseTest
[TestFixture]
public class BlogTests : InMemoryDatabaseTest
{
public BlogTests() : base(typeof(Blog).Assembly)
{
}
[Test]
public void Can_save_and_load_blog()
{
object id;
using (var tx = _session.BeginTransaction())
{
id = _session.Save(new Blog
{
AllowsComments = true,
CreatedAt = new DateTime(2000, 1, 1),
Subtitle = "Hello",
Title = "World",
});
tx.Commit();
}
_session.Clear();
using (var tx = _session.BeginTransaction())
{
var blog = _session.Get<Blog>(id);
Assert.AreEqual(new DateTime(2000, 1, 1), blog.CreatedAt);
Assert.AreEqual("Hello", blog.Subtitle);
Assert.AreEqual("World", blog.Title);
Assert.IsTrue(blog.AllowsComments);
tx.Commit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment