Created
May 19, 2009 17:31
-
-
Save drmohundro/114244 to your computer and use it in GitHub Desktop.
Unit test to go along with Fluent NHibernate version of InMemoryDatabaseTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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