thegladio
10-25-2004, 01:51 AM
I have a grid component which lists the results of a search for people. I want to select a Person row from the grid and open a new window with the details concerning that Person. I want to assign the result of grid.getSelection() to the datapath attribute of my Person class (which extends view). I could go on, but the following test case explains my objective better than I can with words. How can I make this test pass?
<canvas debug="true">
<include href="lzunit" />
<dataset name="ds">
<people>
<person>
<firstname>Homer</firstname>
<lastname>Simpson</lastname>
</person>
<person>
<firstname>Marge</firstname>
<lastname>Simpson</lastname>
</person>
</people>
</dataset>
<class name="Person">
<simplelayout axis="y" />
<view><text>Person</text></view>
<Field id="firstname" datapath="firstname">First Name:</Field>
<Field datapath="lastname">Last Name:</Field>
</class>
<class name="Field">
<simplelayout axis="x" />
<text name="label" text="${parent.text}" />
<text name="value" datapath="text()" />
</class>
<simplelayout axis="y" />
<Person id="person" />
<testsuite>
<testcase>
<method name="test">
//create a stub DataPointer
//Normally the datapointer is provided by
// selectableView.getSelection()
var dp = new LzDataPointer();
dp.setXPath("ds:/people/person[1]");
//assign the datapointer to the datapath attribute
person.setDatapath(dp);
//test
assertEquals("Homer", firstname.value.getText());
</method>
</testcase>
</testsuite>
</canvas>
<canvas debug="true">
<include href="lzunit" />
<dataset name="ds">
<people>
<person>
<firstname>Homer</firstname>
<lastname>Simpson</lastname>
</person>
<person>
<firstname>Marge</firstname>
<lastname>Simpson</lastname>
</person>
</people>
</dataset>
<class name="Person">
<simplelayout axis="y" />
<view><text>Person</text></view>
<Field id="firstname" datapath="firstname">First Name:</Field>
<Field datapath="lastname">Last Name:</Field>
</class>
<class name="Field">
<simplelayout axis="x" />
<text name="label" text="${parent.text}" />
<text name="value" datapath="text()" />
</class>
<simplelayout axis="y" />
<Person id="person" />
<testsuite>
<testcase>
<method name="test">
//create a stub DataPointer
//Normally the datapointer is provided by
// selectableView.getSelection()
var dp = new LzDataPointer();
dp.setXPath("ds:/people/person[1]");
//assign the datapointer to the datapath attribute
person.setDatapath(dp);
//test
assertEquals("Homer", firstname.value.getText());
</method>
</testcase>
</testsuite>
</canvas>