A-A+

【NUnit】CollectionAssert (NUnit 2.4 / 2.5)

2014年12月27日 Nunit 【NUnit】CollectionAssert (NUnit 2.4 / 2.5)已关闭评论 阅读 443 次

CollectionAssert类提供一系列检查两个集合及内容的方法。AreEqual检查两个集合对应元素都相等时则集合相等。AreEquivalent不按照舒顺序检查两个集合内容是否相等。这两种情况都是使用NUnit默认相等比较。

从NUnit2.4.6开始,这些方法都用于实现了IEnumerable接口的对象。2.4.6以前的版本仅支持集合对象。

CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection,
          Type expectedType );
CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection,
          Type expectedType, string message );
CollectionAssert.AllItemsAreInstancesOfType( IEnumerable collection,
          Type expectedType, string message, params object[] args );

CollectionAssert.AllItemsAreNotNull( IEnumerable collection );
CollectionAssert.AllItemsAreNotNull( IEnumerable collection,string message );
CollectionAssert.AllItemsAreNotNull( IEnumerable collection,
          string message, params object[] args );

CollectionAssert.AllItemsAreUnique( IEnumerable collection );
CollectionAssert.AllItemsAreUnique( IEnumerable collection,string message );
CollectionAssert.AllItemsAreUnique( IEnumerable collection,
          string message, params object[] args );

CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual );
CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual,string message );
CollectionAssert.AreEqual( IEnumerable expected, IEnumerable actual
          string message, params object[] args );

CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual);
CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual,
          string message );
CollectionAssert.AreEquivalent( IEnumerable expected, IEnumerable actual
          string message, params object[] args );

CollectionAssert.AreNotEqual( IEnumerable expected, IEnumerable actual );
CollectionAssert.AreNotEqual( IEnumerable expected, IEnumerable actual,
          string message );
CollectionAssert.AreNotEqual( IEnumerableon expected, IEnumerable actual
          string message, params object[] args );

CollectionAssert.AreNotEquivalent( IEnumerable expected,IEnumerable actual );
CollectionAssert.AreNotEquivalent( IEnumerable expected,
          IEnumerable actual, string message );
CollectionAssert.AreNotEquivalent( IEnumerable expected,
          IEnumerable actual, string message, params object[] args );

CollectionAssert.Contains( IEnumerable expected, object actual );
CollectionAssert.Contains( IEnumerable expected, object actual,string message );
CollectionAssert.Contains( IEnumerable expected, object actual
          string message, params object[] args );

CollectionAssert.DoesNotContain( IEnumerable expected, object actual );
CollectionAssert.DoesNotContain( IEnumerable expected, object actual,string message );
CollectionAssert.DoesNotContain( IEnumerable expected, object actual
          string message, params object[] args );

CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset );
CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset,string message);
CollectionAssert.IsSubsetOf( IEnumerable subset, IEnumerable superset,
          string message, params object[] args );

CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset);
CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset,
          string message );
CollectionAssert.IsNotSubsetOf( IEnumerable subset, IEnumerable superset,
          string message, params object[] args );

CollectionAssert.IsEmpty( IEnumerable collection );
CollectionAssert.IsEmpty( IEnumerable collection, string message );
CollectionAssert.IsEmpty( IEnumerable collection, string message,
          params object[] args );

CollectionAssert.IsNotEmpty( IEnumerable collection );
CollectionAssert.IsNotEmpty( IEnumerable collection, string message );
CollectionAssert.IsNotEmpty( IEnumerable collection, string message,
          params object[] args );

 

从NUnit2.5开始,可以使用以下方法:

CollectionAssert.IsOrdered( IEnumerable collection );
CollectionAssert.IsOrdered( IEnumerable collection, string message );
CollectionAssert.IsOrdered( IEnumerable collection, string message, params object[] args );
CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer ); CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer, string message ); CollectionAssert.IsOrdered( IEnumerable collection, IComparer comparer, string message,
                params object[] args );
标签:

评论已关闭!

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

用户登录

分享到: