我得到了部分答案。
使用这些类:
public class BirdCall : fitlibrary.SetUpFixture
{
public void BirdNameNoise(string birdName, string noise)
{
BirdName = birdName;
Noise = noise;
}
public string BirdName;
public string Noise;
public override string ToString()
{
return string.Format("BirdCall: {0}, {1}", BirdName, Noise);
}
}
public class SkylarkBunting : fitlibrary.DoFixture
{
public BirdCall BirdCall;
public string Call;
public Fixture CryOut()
{
BirdCall = new BirdCall();
Call = BirdCall.Noise;
return BirdCall;
}
public string GetCall()
{
return BirdCall.Noise;
}
public string GetName()
{
return BirdCall.BirdName;
}
}
和这个 Wiki 标记:
!define TEST_RUNNER {C:\temp\fitsharp\Runner.exe}
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,c:\temp\fitsharp\fit.dll %p}
!path C:\temp\FitNesseIntegration\bin\Debug\FitnesseIntegration.dll
!|import|
|FitnesseIntegration|
!|FitNesseIntegration.Skylark.SkylarkBunting|
!3 Testing getting data from a setup fixture into a do fixture
!|cry out|
|bird name|noise|
|Tweetie|Caw!|
|check|call||
|check|get call||
|check|get name||
|check|bird call||
我得到:
|check|call|null|
|check|get call|Caw!|
|check|get name|Tweetie|
|check|bird call|BirdCall: Tweetie, Caw!|
这很好,我有变量DoFixture
通过执行SetUpFixture
FitNesse 通过页面注入的值来填充。
不过,我仍然想知道为什么 Call 返回null
。