[英]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.