如何封装方法一到方法二的specflow?

How to encapsulate method 1 to method 2 specflow?

我有以下关于使用SpecFlow框架封装的问题,目标是将方法1封装在方法2中,下面是features/scenarios以及生成的步骤,我想我需要使用 string.format。无论如何,请指教如何将方法1中给出的现有方法封装到方法2中。

首先请看剧情

Scenario Outline: Compare XYZ data against the given templates
Given I have located the XYZ file from <xyzfilelocation>

Examples:
| xyzfilelocation                                                      |
| Tests\Meebu\Doggg\Cat\xyz\Yhyh800\Yhyh800_TheId_1234567.FirstOne.xml |
| Tests\Meebu\Doggg\Cat\xyz\Yhyh800\Yhyh800_TheId_7654321.SecondTwo.xml|

其次查看生成的步骤。

//Method 1

[Given(@"I have located the XYZ file from (.*)")]
public void GivenIHaveLocatedTheXYZFileFromLocation(string xyzfilelocation)
{
string file = new System.IO.DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName + "\" + xyzfilelocation;

_context.ActualXYZ = new XmlDocument();
_context.ActualXYZ.Load(file);
}

//方法二,我想在这里封装上面的方法, 我正在尝试在下面做,这是正确的方法吗?我相信我需要做 string.format 请 advise/will 这项工作是封装吗?

[When(@"I compare XYZ file (.*)")]
public void WhenICompareXYZFile(string xyzfilelocation)
{

//Calling the method Given I have located the XYZ file from <xyzfilelocation>
Given(string.Format("I have located the XYZ file from {0}", xyzfilelocation));
}

您可以像在标准 class 中那样调用该方法: GivenIHaveLocatedTheXYZFileFromLocation(string.Format("I have located the XYZ file from {0}", xyzfilelocation));