A-A+

【NUnit】Type Asserts (NUnit 2.2.3 / 2.5)

2014年12月27日 Nunit 【NUnit】Type Asserts (NUnit 2.2.3 / 2.5)已关闭评论 阅读 477 次

以下方法可以用来对一个对象的类型进行比较。

Assert.IsInstanceOfType( Type expected, object actual );
Assert.IsInstanceOfType( Type expected, object actual, string message );
Assert.IsInstanceOfType( Type expected, object actual, 
                string message, params object[] parms );
                
Assert.IsNotInstanceOfType( Type expected, object actual );
Assert.IsNotInstanceOfType( Type expected, object actual, string message );
Assert.IsNotInstanceOfType( Type expected, object actual, 
                string message, params object[] parms );
            
Assert.IsAssignableFrom( Type expected, object actual );
Assert.IsAssignableFrom( Type expected, object actual, string message );
Assert.IsAssignableFrom( Type expected, object actual, 
                string message, params object[] parms );
                
Assert.IsNotAssignableFrom( Type expected, object actual );
Assert.IsNotAssignableFrom( Type expected, object actual, string message );
Assert.IsNotAssignableFrom( Type expected, object actual, 
                string message, params object[] parms );

从NUnit2.5开始,可以使用.NET2.0的泛型比较。

Assert.IsInstanceOf<T>( object actual );
Assert.IsInstanceOf<T>( object actual, string message );
Assert.IsInstanceOf<T>( object actual, string message, params object[] parms );
                
Assert.IsNotInstanceOf<T>( object actual );
Assert.IsNotInstanceOf<T>( object actual, string message ); 
Assert.IsNotInstanceOf<T>( object actual, string message, params object[] parms );
            
Assert.IsAssignableFrom<T>( object actual );
Assert.IsAssignableFrom<T>( object actual, string message );
Assert.IsAssignableFrom<T>( object actual, string message, params object[] parms );
                
Assert.IsNotAssignableFrom<T>( object actual );
Assert.IsNotAssignableFrom<T>( object actual, string message );
Assert.IsNotAssignableFrom<T>( object actual, string message, params object[] parms );
标签:

评论已关闭!

Copyright © 极品飞鸽 保留所有权利.   Theme  Ality 蜀ICP备14015766号-1

用户登录

分享到: