I wonder if what I want to do is possible. I have a unit test driven by a xml, as follow :
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
"|DataDirectory|\\MyFile.xml",
"TestMember",
DataAccessMethod.Sequential)]
[DeploymentItem("MyFile.xml")]
[TestMethod]
public void Hello()
{
...
}
where MyFile.xml looks like this :
<TestMembers>
<TestMember>
<Name>Hello</Name>
<id>1234</id>
<MyComplexRow>
<MySerializedInstanceOfClass>
<BooleanProperty>true</BooleanProperty>
<IntProperty>8</IntProperty>
<MySerializedInstanceOfAnotherClass>
<int>23</int>
<bool>false</bool>
<double>8.0</double>
</MySerializedInstanceOfAnotherClass>
</MySerializedInstanceOfClass>
</MyComplexRow>
</TestMember>
</TestMembers>
Now the problem is that accessing TestContext.DataRow["Name"]
works fine, but I can't access the TestContext.DataRow["MyComplexRow"]
, I get a Column 'MyComplexRow' does not belong to table TestMember.
because it's not a "scalar", but has many dimensions...
So, is there any way I could trick Visual Studio to let him know he's dealing with a serialized instance of an existing class ? Like, extending an existing class perhaps.
I know I could wrap it all up in CDATA and then deserialize it, but, well, it's not as elegant.
Thanks !