2009-07-09 9 views
4

Comment faites-vous l'équivalent de:Comment utiliser ExpectedException dans les tests C++/CLI NUnit?

[Test, ExpectedException(typeof(ArgumentOutOfRangeException))] 
void Test_Something_That_Throws_Exception() 
{ 
    throw gcnew ArgumentOutOfRangeException("Some more detail"); 
} 

... en C++ (l'exemple il y a C#)? Pour autant que je puisse voir, il n'y a pas de fonction typeof() pour l'implémentation C++ de NUnit.

Répondre

7

Pour éviter que quelqu'un d'autre chasse des âges essayant de trouver, voici la solution:

[Test, ExpectedException(ArgumentOutOfRangeException::typeid)] 
void Test_Something_That_Throws_Exception() 
{ 
    throw gcnew ArgumentOutOfRangeException("Some more detail"); 
} 

simplement utiliser le ::typeid de l'exception :-)

Questions connexes