Try fast search NHibernate

21 June 2009

How much I like NUnitEx

It is so fluent….

// NUnit classic Assertion
Assert.AreEqual("1;2;3", (new[] {"1", "2"}).ConcatWithSeparator(';'));

// NUnit classic Constraints
Assert.That((new[] { "1", "2", "3" }).ConcatWithSeparator(';'), Is.EqualTo("1;2;3"));

// NUnitEx
(new[] { "1", "2", "3" }).ConcatWithSeparator(';').Should().Be.EqualTo("1;2;3");

No ?

s.CreateQuery("from EntityWithPropNames e where e.PropertiesNames like '%p2%'")
.UniqueResult<EntityWithPropNames>()
.PropertiesNames
.Should().Have.SameSequenceAs(new[] {"p1", "p2", "p3"});

2 comments:

  1. Hi Fabio,

    this is the third time I write this comment here. This time in Textmate. Had some issues with copy/paste and open id :-( Can't copy/and paste in firefox (mac), and when the authorization fails, the comment is lost.

    I've been using NUnitEx and I like it alot better than the old assertion syntax. I think it is mostly because of the natural order of computation, constraint and actual value.

    computation, constraint, actual value in
    "computation".constraint("actual")

    is much more natural than

    constraint(actual, computation)

    Allthough I miss a shortcut to the most common constraints:

    Sorry for bringing it up again, but this time I only ask for some most common ones. Intellisense then helps for more complex constraints using Should()...

    "x".Should.Be.EqualTo("x")
    "x".ShouldEqual("x")

    user.Should.Not.Be.Null().FirstName.Should.Be.EqualTo("Lars");
    user.ShouldNotBeNull().FirstName.ShouldEqual("Lars");

    The second versions are huge advancement especially in terms of readability.

    ReplyDelete
  2. Hi Lars. I can't do nothing about the problem of copy&paste openID.

    Can you please use the issue tracker of NUnitEx ?

    Perhaps the short-cut about EqualTo can be useful even if I prefer
    actual.Should().Be.EqualTo(expected);

    ReplyDelete