Hi everyone

What about this: If we define an enumeration like the following:

    public enum MbUnitSpecialValue
        {
                Null
        }

And then we modify the RowTestAttribute's GetRow method to change
every occurrence of MbUnitSpecialValue.Null for null, then we could
write Judah's test like this:

[RowTest]
[Row(MbUnitSpecialValue.Null, bar, baz, ExpectedException
=typeof(ArgumentNullException)]
[Row(foo, MbUnitSpecialValue.Null, baz, ExpectedException
=typeof(ArgumentNullException)]
[Row(foo, bar, MbUnitSpecialValue.Null, ExpectedException
=typeof(ArgumentNullException))]
public void FobnicateValidatesInput(Foo foo, Bar bar, Baz baz)
{
   dar.Fobnicate(foo, bar, baz);
}

That would be a fast change, but it doesn't solve the more general
problem that we face for using attributes to the define the rows:

- We can't use anything but primitive types
- VB 2003 compiler can't handle the Row attribute
- With C# 2003 we can't use null in the attribute (it works on C# 2005
at least).

Using a "row provider" is the best choice IMHO. In this blopg post
http://www.hpoffice.cl/julian/archive/2007/04/17/mbunit-rowtest-in-vb-2003.aspx
I proposed something similar to Jay's first example (using arrays
instead of generics so it works for Fx1.1 too):

        [RowProvider]
        public IEnumerable RowsForLengthTest()
        {
            object[] row1 = { "M", 1 };
            object[] row1 = { "Mb", 2, GetType(ArgumentNullException) };
            object[][] rowArray = { row1, row2 };
            return rowArray;
        }

        [RowTest(), Provider("RowsForLengthTest")]
        public void LenghtTest(string someString, int length)
        {

            Assert.AreEqual(someString.Length, length);

        }

I'm not that worried about the key part, because these are tests so a
developer (or anyone) should find very quickliy if she got's a key
wrong. Besides, we are already using keys for combinatorial tests for
example.

To be honest I found the last example (using [NonNullArgument]) a
little confusing and harder to read that the first solution.

Regards
Julián

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to