1

我针对 .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;
        }
    }
}

感谢帮助。

4

1 回答 1

0

只使用一个创建客户对象列表的类会更简单,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|

http://fitsharp.github.io/Fit/FixtureWrapper.html

于 2016-01-13T19:08:55.720 回答