Ok, now I see what you are trying to do. You want the fixture to loop over
persons and the test to loop over tests.
Hierarchical nested loops over data sources are not supported at this time.
However you can use multiple data sources together if you like. An outer one
for persons and an inner one for tests.
Still, is there any problem with just doing this?
[XmlData("//Person", FilePath = "Data.xml")]
public void Test([Bind("../@name")] string personName, [Bind("@name")] string
testName)
{
}
The test will run once for each person & corresponding test name pair. It
won't have a nice hierarchical structure in the report but it will at least run
with the right data.
Jeff.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of max2256
Sent: Wednesday, February 11, 2009 8:10 AM
To: MbUnit.User
Subject: MbUnit Re: XmlData
I've used //Person/Test instead and then ../@name, but did not work. I obtained
this :
Person("Mike")
|_ _ Test("x")
|_ _ Test("y")
|_ _ Test("z")
|_ _ Test("w")
Person("Mike")
|_ _ Test("x")
|_ _ Test("y")
|_ _ Test("z")
|_ _ Test("w")
Person("Jim")
|_ _ Test("x")
|_ _ Test("y")
|_ _ Test("z")
|_ _ Test("w")
Person("Jim")
|_ _ Test("x")
|_ _ Test("y")
|_ _ Test("z")
|_ _ Test("w")
I think this is normal because by putting [XmlData("//Person/Test", FilePath =
"Data.xml")] at class level, this will loop on the Test node so this is why I
get Mike and Jim twice!
I've also tried this but did not succeed!!
[XmlData("//Person", FilePath = "Data.xml")] public class Fixture {
public Fixture([Bind("@name")] string name) { }
[Test]
public void Test([Bind("Test/@name")] string testName) {} }
I get :
Person("Mike")
|_ _ Test("x")
|_ _ Test("z")
Person("Jim")
|_ _ Test("x")
|_ _ Test("z")
It still does not loop on the Test tag.....could this be a bug?
Max
On Feb 11, 12:02 am, Jeff Brown <[email protected]> wrote:
> That is correct. It loops over the Persons because that is what was
> specified as the "row level" selector.
>
> You might want to use //Person/Test instead. You can then bind to the
> person name attribute if you want using an uplevel selector like ../
> @name
>
> Jeff.
>
> On Feb 10, 2009, at 11:21 AM, max2256 <[email protected]> wrote:
>
>
>
> > I've tried with the slash and got the following output:
>
> > Person("Mike")
> > |_ _ Test("x")
> > |_ _ Test("x")
>
> > Person("Jim")
> > |_ _ Test("x")
> > |_ _ Test("x")
>
> > Looks like it doesn't loop on the Test tag!
>
> > On Feb 10, 1:44 pm, Marcus Griep <[email protected]> wrote:
> >> I totally forgot a slash in there. Try using this instead: "Test/
> >> @name".
> >> If that doesn't work, then there might be something functionally
> >> different with getting XmlData to work the way you want it to.
> >> --
> >> Marcus Griep
> >> ——
> >> Ακακια את.ψο´, 3°
>
> >> On Tue, Feb 10, 2009 at 12:59 PM, max2256 <[email protected]>
> >> wrote:
>
> >>> Thank you Marcus for your response, but I've tried your solution
> >>> but did not succeed!
> >>> The problem is that it give a failure saying that
> >>> [Bind("t...@name")] is not a valid expression.
>
> >>> On Feb 9, 3:42 pm, Marcus Griep <[email protected]> wrote:
> >>>> Your xpath query seems to be a bit off.
> >>>> "//Person" means give me all person nodes everywhere. Similarly,
> >>> "//Test"
> >>>> means give me all test nodes everywhere. This causes w, x, y,
> >>>> and z to
> >>> be
> >>>> selected.
>
> >>>> I am not exactly sure how to organize this to get the effect you
> >>>> are
> >>> looking
> >>>> for, but maybe this?:
>
> >>>> [XmlData("//Person", FilePath = "data.xml")] public
> >>>> Fixture([Bind("@name")] string name) { }
>
> >>>> [XmlData("//Person", FilePath = "data.xml")] public void
> >>>> Test([Bind("t...@name")] string testName) { }
> >>>> --
> >>>> Marcus Griep
> >>>> ——
> >>>> Ακακια את.ψο´, 3°
>
> >>>> On Mon, Feb 9, 2009 at 2:57 PM, max2256 <[email protected]>
> >>>> wrote:
>
> >>>>> Hi!
> >>>>> I've been testing the XmlData attribute for a while, but I've
> >>>>> not been able to solve the following problem:
>
> >>>>> let's say I have this XML file (data.xml) for example:
> >>>>> <Fixture>
> >>>>> <Person name="Mike">
> >>>>> <Test name="x"></Test>
> >>>>> <Test name="y"></Test>
> >>>>> </Person>
> >>>>> <Person name="Jim">
> >>>>> <Test name="z"></Test>
> >>>>> <Test name="w"></Test>
> >>>>> </Person>
> >>>>> </Fixture>
>
> >>>>> How can I loop on the Test node for this particular person ?
>
> >>>>> I tried this way but it did not succeed:
>
> >>>>> public class Fixture
> >>>>> {
> >>>>> [XmlData("//Person", FilePath = "data.xml")]
> >>>>> public Fixture([Bind("@name")] string name)
> >>>>> {
> >>>>> // do something
> >>>>> }
>
> >>>>> [XmlData("//Test", FilePath = "data.xml")]
> >>>>> public void Test([Bind("@name")] string testName)
> >>>>> {
> >>>>> //do something
> >>>>> }
> >>>>> }
>
> >>>>> When I ran this I obtain this :
>
> >>>>> Person("Mike")
> >>>>> |_ _ Test("x")
> >>>>> |_ _ Test("y")
> >>>>> |_ _ Test("z")
> >>>>> |_ _ Test("w")
>
> >>>>> Person("Jim")
> >>>>> |_ _ Test("x")
> >>>>> |_ _ Test("y")
> >>>>> |_ _ Test("z")
> >>>>> |_ _ Test("w")
>
> >>>>> Any suggestions?
>
> >>>>> Thanx
>
> >>>>> On Feb 7, 5:09 am, "Jeff Brown" <[email protected]> wrote:
> >>>>>> There's actually a bunch of docs and examples on the attribute
> >>>>>> class
> >>>>> itself.
>
> >>>>>> Hit F1 on the type and see what Visual Studio shows you.
> >>>>>> (Caveat: It
> >>>>> might
> >>>>>> take a bit for VS to regenerate its help index the first time.
> >>>>>> This
> >>> is
> >>>>>> annoying but normal.)
>
> >>>>>> Jeff.
>
> >>>>>> -----Original Message-----
> >>>>>> From: [email protected] [mailto:
> >>> [email protected]]
> >>>>> On
>
> >>>>>> Behalf Of max2256
> >>>>>> Sent: Friday, February 06, 2009 10:56 AM
> >>>>>> To: MbUnit.User
> >>>>>> Subject: MbUnit XmlData
>
> >>>>>> Hi,
>
> >>>>>> I've installed the current build and I'm very
> >>>>>> interested in using the XMLData attribute, but I could not find
> >>>>>> any
> >>> documentation
> >>>>>> on how to use it! Is is possible to post a snippet on how to
> >>>>>> use it
> >>> or
> >>>>> it's
> >>>>>> too soon to use this attribute.
>
> >>>>>> Thanx- Hide quoted text -
>
> >>>>>> - Show quoted text -- Hide quoted text -
>
> >>>> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---