当前位置: 首页 > news >正文

[翻译]NUnit---String Collection File Directory Assert (七)

StringAssert (NUnit 2.2.3)

StringAssert类提供一系列检查字符串的方法。

 

View Code
StringAssert.Contains( string expected, string actual );
StringAssert.Contains( string expected, string actual, 
                string message );
StringAssert.Contains( string expected, string actual,
                string message, params object[] args );

StringAssert.StartsWith( string expected, string actual );
StringAssert.StartsWith( string expected, string actual, 
                string message );
StringAssert.StartsWith( string expected, string actual,
                string message, params object[] args );

StringAssert.EndsWith( string expected, string actual );
StringAssert.EndsWith( string expected, string actual, 
                string message );
StringAssert.EndsWith( string expected, string actual,
                string message, params object[] args );

StringAssert.AreEqualIgnoringCase( string expected, string actual );
StringAssert.AreEqualIgnoringCase( string expected, string actual, 
                string message );
StringAssert.AreEqualIgnoringCase( string expected, string actual,
                string message params object[] args );
                
StringAssert.IsMatch( string regexPattern, string actual );
StringAssert.IsMatch( string regexPattern, string actual, 
                string message );
StringAssert.IsMatch( string regexPattern, string actual,
                string message, params object[] args );

 

CollectionAssert (NUnit 2.4 / 2.5)

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

 

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

 

View Code
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开始,可以使用以下方法:

View Code
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 );

 

FileAssert (NUnit 2.4)


FileAssert类提供了比较两个文件的方法,包括StreamFileInfo、指定文件路径string的参数格式。

 

View Code
FileAssert.AreEqual( Stream expected, Stream actual );
FileAssert.AreEqual( Stream expected, Stream actual, 
                string message );
FileAssert.AreEqual( Stream expected, Stream actual,
                string message, params object[] args );

FileAssert.AreEqual( FileInfo expected, FileInfo actual );
FileAssert.AreEqual( FileInfo expected, FileInfo actual, 
                string message );
FileAssert.AreEqual( FileInfo expected, FileInfo actual,
                string message, params object[] args );

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

FileAssert.AreNotEqual( Stream expected, Stream actual );
FileAssert.AreNotEqual( Stream expected, Stream actual, 
                string message );
FileAssert.AreNotEqual( Stream expected, Stream actual,
                string message, params object[] args );

FileAssert.AreNotEqual( FileInfo expected, FileInfo actual );
FileAssert.AreNotEqual( FileInfo expected, FileInfo actual, 
                string message );
FileAssert.AreNotEqual( FileInfo expected, FileInfo actual,
                string message, params object[] args );

FileAssert.AreNotEqual( string expected, string actual );
FileAssert.AreNotEqual( string expected, string actual, 
                string message );
FileAssert.AreNotEqual( string expected, string actual,
                string message, params object[] args );

 

DirectoryAssert (NUnit 2.5)

DirectoryAssert类提供了一系列方法来比较文件系统目录,DirectoryInfo或者指定目录路径的string格式的参数。

DirectoryAssert.AreEqual() and DirectoryAssert.AreNotEqual() 比较两个目录是否相等。如果目录有相同的FullName, Attributes, CreationTime and LastAccessTime则认为是相等。

Note:如果不满足以上条件即使两个不同目录包含相同的文件也不相等

 

View Code
DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual );
DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual, 
                string message );
DirectoryAssert.AreEqual( DirectoryInfo expected, DirectoryInfo actual,
                string message, params object[] args );

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

DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual );
DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual, 
                string message );
DirectoryAssert.AreNotEqual( DirectoryInfo expected, DirectoryInfo actual,
                string message, params object[] args );

DirectoryAssert.AreNotEqual( string expected, string actual );
DirectoryAssert.AreNotEqual( string expected, string actual, 
                string message );
DirectoryAssert.AreNotEqual( string expected, string actual,
                string message, params object[] args );

DirectoryAssert.IsEmpty() and DirectoryAssert.IsNotEmpty() 检测指定的目录是否为empty

View Code
DirectoryAssert.IsEmpty( DirectoryInfo directory );
DirectoryAssert.IsEmpty( DirectoryInfo directory, string message );
DirectoryAssert.IsEmpty( DirectoryInfo directory,
                string message, params object[] args );

DirectoryAssert.IsEmpty( string directory );
DirectoryAssert.IsEmpty( string directory, string message );
DirectoryAssert.IsEmpty( string directory,
                string message, params object[] args );

DirectoryAssert.IsNotEmpty( DirectoryInfo directory );
DirectoryAssert.IsNotEmpty( DirectoryInfo directory, string message );
DirectoryAssert.IsNotEmpty( DirectoryInfo directory,
                string message, params object[] args );

DirectoryAssert.IsNotEmpty( string directory );
DirectoryAssert.IsNotEmpty( string directory, string message );
DirectoryAssert.IsNotEmpty( string directory,
                string message, params object[] args );

DirectoryAssert.IsWithin() and DirectoryAssert.IsNotWithin()检测第二个目录是否是第一个目录的直接或者间接子目录。

 

View Code
DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual );
DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual,
                string message );
DirectoryAssert.IsWithin( DirectoryInfo expected, DirectoryInfo actual,
                string message, params object[] args );

DirectoryAssert.IsWithin( string expected, string actual );
DirectoryAssert.IsWithin( string expected, string actual,
                string message );
DirectoryAssert.IsWithin( string expected, string actual,
                string message, params object[] args );

DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual );
DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual,
                string message );
DirectoryAssert.IsNotWithin( DirectoryInfo expected, DirectoryInfo actual,
                string message, params object[] args );

DirectoryAssert.IsNotWithin( string expected, string actual );
DirectoryAssert.IsNotWithin( string expected, string actual,
                string message );
DirectoryAssert.IsNotWithin( string expected, string actual,
                string message, params object[] args );

 

转载于:https://www.cnblogs.com/kim01/archive/2013/04/13/3019308.html

相关文章:

  • DataTable对象重组时,错误提示“该行已经属于另一个表”
  • hdu 2516博弈找规律
  • SQL查询:主从表 报表方式显示
  • Linux图形界面中客户端、服务器、窗口管理器之间的关系
  • paste命令
  • 一篇故事讲述了计算机网络里的基本概念:网关,DHCP,IP寻址,ARP欺骗,路由,DDOS等...
  • Winform开发框架之混合型框架的剖析
  • 折腾13年——Leo张大志小传
  • 《C++.GUI.Programming.with.Qt.4》读书笔记Chapter 1~2
  • 学习 easyui 之二:jQuery 的 ready 函数和 easyloader 的加载回调函数
  • AS3应用程序模块化开发与ApplicationDomain
  • Access restriction: The type BASE64Encoder is not accessible due to restrict
  • 什么是x-window
  • Unity3D 关于yield在collider中的使用
  • ultraWinGrid绑定下拉框
  • angular组件开发
  • css的样式优先级
  • electron原来这么简单----打包你的react、VUE桌面应用程序
  • Nginx 通过 Lua + Redis 实现动态封禁 IP
  • RxJS: 简单入门
  • zookeeper系列(七)实战分布式命名服务
  • 道格拉斯-普克 抽稀算法 附javascript实现
  • 开源中国专访:Chameleon原理首发,其它跨多端统一框架都是假的?
  • 微服务框架lagom
  • (env: Windows,mp,1.06.2308310; lib: 3.2.4) uniapp微信小程序
  • (第27天)Oracle 数据泵转换分区表
  • (未解决)jmeter报错之“请在微信客户端打开链接”
  • (转)Oracle存储过程编写经验和优化措施
  • (转载)OpenStack Hacker养成指南
  • (轉貼) 寄發紅帖基本原則(教育部禮儀司頒布) (雜項)
  • ./configure、make、make install 命令
  • .Net 6.0 处理跨域的方式
  • .Net Memory Profiler的使用举例
  • .NET NPOI导出Excel详解
  • .NET WebClient 类下载部分文件会错误?可能是解压缩的锅
  • .Net 高效开发之不可错过的实用工具
  • .net 托管代码与非托管代码
  • .net 验证控件和javaScript的冲突问题
  • .net6 webapi log4net完整配置使用流程
  • .net流程开发平台的一些难点(1)
  • .net使用excel的cells对象没有value方法——学习.net的Excel工作表问题
  • .net中应用SQL缓存(实例使用)
  • .set 数据导入matlab,设置变量导入选项 - MATLAB setvaropts - MathWorks 中国
  • .xml 下拉列表_RecyclerView嵌套recyclerview实现二级下拉列表,包含自定义IOS对话框...
  • :如何用SQL脚本保存存储过程返回的结果集
  • ??在JSP中,java和JavaScript如何交互?
  • @Autowired自动装配
  • @德人合科技——天锐绿盾 | 图纸加密软件有哪些功能呢?
  • [20160807][系统设计的三次迭代]
  • [ACM] hdu 1201 18岁生日
  • [Angular] 笔记 6:ngStyle
  • [Angular] 笔记 7:模块
  • [BUG] Hadoop-3.3.4集群yarn管理页面子队列不显示任务
  • [BZOJ]4817: [Sdoi2017]树点涂色
  • [BZOJ1877][SDOI2009]晨跑[最大流+费用流]