[英]Rowfixture in .NET to call a web service with Inputs and validate response object
我已经针对.NET实施了以下FitNesse测试。 它使用“ RowFixture”返回已验证的对象。 所有这些都可以。
我的问题是,如何将FIT测试中的“输入”传递给阵列? 在常规情况下,这是内部硬编码的。
这是FIT测试:
!|ReturnObjectMultiDimension|
|Id |Name |
|1, 2, 3, 4 |a, b, c, d |
这是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using fit;
using dbfit;
namespace DbFitProject
{
public class ReturnObjectMultiDimension : RowFixture
{
public override Type GetTargetClass()
{
return typeof(CustomerObject);
}
public override object[] Query()
{
CustomerObject[] array = new CustomerObject[1];
array[0] = new CustomerObject(new int[4] { 1, 2, 3, 4 }, new string[4] {"a","b","c","d" });
return array;
}
}
public class CustomerObject
{
public int[] Id;
public string[] Name;
public CustomerObject(int[] Id, string[] Name)
{
this.Id = Id;
this.Name = Name;
}
}
}
感谢帮助。
拥有一个创建客户对象列表的类会更简单,fitSharp会自动将列表包装在夹具中以检查结果:
public class MyClass {
public List<CustomerObject> MakeListWithIdsNames(int[] ids, string[] names) {
return new List<CustomerObject> { new CustomerObject(ids, names) };
}
}
|my class|
|make list with ids|1,2,3,4|names|a,b,c,d|
|id|name|
|1,2,3,4|a,b,c,d|
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.