Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Variables

Matthias Koch edited this page Aug 14, 2015 · 3 revisions

It is essential in SpecK to create fields only for tested actions and subject creation. One could also declare fields for other variables necessary in certain tests, however, this would break locality. Instead, SpecK offers the GivenVars method and the Vars test context property to pass objects between delegates:

decimal Amount;

BankAccountSpec()
{
  Specify (x => x.Calculate(Amount))
      .DefaultCase (_ => _
           .GivenVars (x => new { MyAmount = 10m })
           .Given (x => Amount = x.Vars.MyAmount)
           // ...
}
Clone this wiki locally