I actually cheated in the end and used a Dictionary<string,
Func<string>>, then looked up the property that way. Naughty in terms
of not producing well-enclosed tests, but good in that my duplicated
code within the test class went from 70% > 5%

On May 5, 7:40 pm, "Jeff Brown" <[email protected]> wrote:
> Attribute arguments must be compile-time constants or array-creation
> expressions.  This is a limitation of the .Net CIL, not something MbUnit can
> fix.
>
> Your best bet here is probably to encode the property names as strings and
> use reflection.
>
> That said, I recommend using separate test methods in this case since it
> will be clearer to the reader what is going on (even if there is a little
> duplication).
>
> [Test]
> public void UpdateProperties_WhenDataContainsPrefix04_SetsTheIP()
> {
>     _testClassUnderTest.UpdateProperties(new byte[] { 0x04, 101, 102, 103,
> 104 });
>
>     Assert.AreEqual("101.102.103.104", _testClassUnderTest.IP);
>
> }
>
> Jeff.
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
>
> Behalf Of Abynthe
> Sent: Tuesday, May 05, 2009 4:18 AM
> To: MbUnit.User
> Subject: MbUnit Testing properties with rowtest
>
> In trying to check that a set of properties are correctly updated
> appropriately I came across a difficulty in attempting to access properties
> during a row test.
>
> Ideally, I want to do something like this:
>
> [Test]
> [Row( new byte[] { 0x04, 101, 102, 103, 104 } , new
> Expression<Func<ClassUnderTest, string>>[]{c => c.IP}, "101.102.103.104")]
> public void ParameterisedPropertyUpdateTest(byte[] data,
> Expression<Func<ClassUnderTest, string>>[] propertyAccessor, string
> expectedValue)
>         {
>             _testClassUnderTest.UpdateProperties(data);
>             Assert.AreEqual(expectedValue, propertyAccessor[0].Compile
> ().Invoke(_testClassUnderTest));
>         }
>
> Is there any way to access properties in this (or any other) manner during
> rowtest?
--~--~---------~--~----~------------~-------~--~----~
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