FIT FOR DOT NET (6)----RowFixture

原创 2005年03月03日 13:34:00

对于ColumnFixture,我认为比较复杂,所以我用的不太多,在这里我把它的理解说一下,其中很多观点来源于其网站.

Row Fixture

RowFixture将测试数据的行和测试下系统的对象作比较,方法在对象以及与表数据比较的返回值上调用,一个算法符合带有基于一个或者多个键对象的行.对象可以遗漏,也可多余,这些都是需要注意的.

下面的Q&A来自其网站:


Q: RowFixture.match is kind of hard to understand. Obviously I did not know anything about it but some more info on its matching algorithm on its wiki page might help the novice reader like me. Do you think that it could be refactored to help the common brains like mine grok it?

A: RowFixture was very hard to get right until I found the current factoring. The algorithm is a variation on the bucket sort where two parallel sorts are taking place, one of the expected rows and another for the computed rows.

The fixture processes all the rows of one table following these five steps:

  • bind the columns to variables and methods by reflection.
  • query to get the result rows which will be checked.
  • match the expected and result rows and check the matches.
  • build html for missing rows.
  • mark mark missing and surplus rows as such.

Of these steps the match is the most complex. The matching algorithm is one of divide and conquer using a method that calls itself recursively in two circumstances:

  • recurse matching subsets of the expected and computed rows distinguished by unique values in a specific column.

  • recurse so as to examine the next available column when the current column doesn't successfuly bind to any field or method.

Each invocation of the method divides the expected and computed rows into sublists with equal values in the current column of interest. (This is the "sort" step, as in sorting clothes into like piles.) Each sublist (pile) is considered in turn. There are four cases:

  • the expected list is empty so computed rows are surplus.
  • the computed list is empty so expected rows are missing.
  • there is exactly one row in each list so compare them.
  • otherwise the match is ambiguous so further sorting on subsequent columns is required.

The method uses several helper functions which are sometimes duplicated because of representational differences between the expected rows (Parse objects) and the computed rows (Domain objects).


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Node.js for dot net

  • 2016-02-08 14:35
  • 12.63MB
  • 下载

Office编程在dot Net环境中总结(Excel篇)

文章的使用范围    运行环境 .net Framework 1.1 ,Excel 2003    开发语言:C#   目录 1.0简要说明     2.0 Excel 编程模型的说明。 ...

dot net npoi

前言 最近项目中,需要使用到 Excel 导出,找了一圈发现没有适用于 .NET Core的,不依赖Office和操作系统限制的 Office 组件,于是萌生了把 NPOI 适配并移植到 .NET C...

Dot NET设计模式—反射工厂

Dot NET设计模式—反射工厂  1.概述         如果采用传统方式实现了简单工厂、工厂方法和抽象工厂在有些场合下如此处理,代码会变得冗余并且难以维护。         假设我们需要创...

dot Net 线程相关问题

把遇到过的对.Net线程的一些问题和误解集中起来和大家分享,也希望大家能一起补充,热烈欢迎讨论 目录 基础篇怎样创建一个线程受托管的线程与 Windows线程前台线程与后台线程名为BeginXXX和...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)