.NET中损坏的DataSet用于失败测试(Corrupted DataSet in .NET for failure testing)

有谁知道创建DataSet的方式,以至于当我在DataSet上调用GetXml()时,我会得到一个异常? 我正在尝试为这种情况写一些失败测试,​​并且很难。 可能吗?

Does anybody know of a way to create a DataSet such that when I call GetXml() on the DataSet I will get an exception? I'm trying to write some failure testing for this scenario and am having a hard time. Is it possible?

最满意答案

你可以写一个DataSet的子类,使它的getXml()可以抛出异常吗?

Can you write a subclass of DataSet such that its getXml() predictably throws an Exception?

.NET中损坏的DataSet用于失败测试(Corrupted DataSet in .NET for failure testing)

有谁知道创建DataSet的方式,以至于当我在DataSet上调用GetXml()时,我会得到一个异常? 我正在尝试为这种情况写一些失败测试,​​并且很难。 可能吗?

Does anybody know of a way to create a DataSet such that when I call GetXml() on the DataSet I will get an exception? I'm trying to write some failure testing for this scenario and am having a hard time. Is it possible?

最满意答案

你可以写一个DataSet的子类,使它的getXml()可以抛出异常吗?

Can you write a subclass of DataSet such that its getXml() predictably throws an Exception?