All 2 entries tagged Tdd

No other Warwick Blogs use the tag Tdd on entries | View entries tagged Tdd at Technorati | There are no images tagged Tdd on this blog

November 01, 2006

Nemerle, NUnit and custom operators

Nemerle allows the definition of new operators. I always feel annoyed having to write code like “Assert.AreEqual(42, myVal)” when unit testing with NUnit.

So I created this operator for use in my project’s test library:

namespace Equin.Vectorization.Library.Tests
    module Utilities
        public static @=!=[T](x : T, y : T) : void
            Assert.AreEqual(x, y)

Now in my test cases I can use it like this:

[Test] public PixelAtTopLeft() : void
    using (bmp = CreateBitmap(Size(10, 10), [Pt(0,0)]))
        def ps = PixelSelector(bmp, Color.Black)
        def pixels = ps.GetPixels()

        mutable count = 0
        mutable aPoint : Pt[int] = null
        foreach (pt in pixels)
            count++
            aPoint = pt

        1 =!= count
        0 =!= aPoint.X
        0 =!= aPoint.Y

It’s just sugar, I know, but it makes the assertions really jump out at me. It’s less to type as well :)
I could even make it a macro instead of a method call, that would then let me create a pretty message string as well…


June 27, 2006

Rhino Mocks Boo Macros Released

Writing about web page http://www.equin.co.uk/boo/rmbm.htm

My Boo syntactic macros for the Rhino Mocks mock object library are available to test. I've only spent a few days working on them but they are already powerful.

For download links and docs see preliminary documentation


Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help http://www.webmd.com/eye–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry

Tags

October 2014

Mo Tu We Th Fr Sa Su
Sep |  Today  |
      1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31      

Galleries

Blog archive

Loading…
RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXIV