NHProfAlive! It is alive!

time to read 2 min | 353 words

I just finished writing the final test for the basic functionality that I want for NHibernate Profiler:

        [Test]
public void SelectBlogById()
{
ExecuteScenarioInDifferentProcess<SelectBlogByIdUsingCriteria>();
StatementModel selectBlogById = observer.Model.Sessions.First()
.Statements.First();
const string expected = @"SELECT this_.Id as Id3_0_,
this_.Title as Title3_0_,
this_.Subtitle as Subtitle3_0_,
this_.AllowsComments as AllowsCo4_3_0_,
this_.CreatedAt as CreatedAt3_0_
FROM Blogs this_
WHERE this_.Id = @p0

";
Assert.AreEqual(expected, selectBlogById.Text);
}

I actually had to invest some thought about the architecture of testing this. This little test has a whole set of ideas behind it, about which I'll talk about at a later date. Suffice to say that this test creates a new process, start to listen to interesting things that are going on there (populating the observer model with data).

Another interesting tidbit is that the output is formatted for readability. By default, NHiberante's SQL output looks something like this:

SELECT this_.Id as Id3_0_, this_.Title as Title3_0_, this_.Subtitle as Subtitle3_0_, this_.AllowsComments as AllowsCo4_3_0_, this_.CreatedAt as CreatedAt3_0_ FROM Blogs this_ WHERE this_.Id = @p0

This is pretty hard to read the moment that you have any sort of complex conditions.

More posts in "NHProf" series:

  1. (02 Dec 2008) What is the role of the DBA?
  2. (01 Dec 2008) The stack is not as simple as you wish it to be
  3. (21 Oct 2008) Logging interception
  4. (13 Oct 2008) Another milestone
  5. (13 Oct 2008) Alive! It is alive!