简体   繁体   English

.NET中的Rowfixture以使用Inputs调用Web服务并验证响应对象

[英]Rowfixture in .NET to call a web service with Inputs and validate response object

I have the following FitNesse test implemented against .NET. 我已经针对.NET实施了以下FitNesse测试。 It uses "RowFixture" to return an object which is verified. 它使用“ RowFixture”返回已验证的对象。 All this works ok. 所有这些都可以。

My Question is, how can I pass the "inputs" to the array from the FIT test? 我的问题是,如何将FIT测试中的“输入”传递给阵列? At the monent, this is hard coded internally. 在常规情况下,这是内部硬编码的。

Here is the FIT test: 这是FIT测试:

!|ReturnObjectMultiDimension|
|Id           |Name         |
|1, 2, 3, 4   |a, b, c, d   |

Here is the code: 这是代码:

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;
        }
    }
}

Thanks for help. 感谢帮助。

It's simpler to just have a class that creates a customer object list and fitSharp will automatically wrap the list in a fixture to check the results: 拥有一个创建客户对象列表的类会更简单,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|

See http://fitsharp.github.io/Fit/FixtureWrapper.html 参见http://fitsharp.github.io/Fit/FixtureWrapper.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM