如何在C ++ / CLI NUnit测试中使用ExpectedException? [英] How do I use ExpectedException in C++/CLI NUnit tests?
本文介绍了如何在C ++ / CLI NUnit测试中使用ExpectedException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何做相当于:
[Test, ExpectedException( typeof(ArgumentOutOfRangeException) )]
void Test_Something_That_Throws_Exception()
{
throw gcnew ArgumentOutOfRangeException("Some more detail");
}
...在C ++中(示例中有C#)?就我所见,NUnit的C ++实现没有typeof()函数。
...in C++ (the example there is C#)? As far as I can see, there's no typeof() function for the C++ implementation of NUnit.
推荐答案
尝试找到它的年龄,这里的解决方案:
To avoid anyone else hunting around for ages trying to find it, here's the solution:
[Test, ExpectedException( ArgumentOutOfRangeException::typeid )]
void Test_Something_That_Throws_Exception()
{
throw gcnew ArgumentOutOfRangeException("Some more detail");
}
只需使用 :: typeid
的异常: - )
Simply use the ::typeid
of the exception :-)
这篇关于如何在C ++ / CLI NUnit测试中使用ExpectedException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文