如何基于集成组件创建带有上下文的单元测试?
我已经确定了问题,因为扩展正在尝试解决实现并返回错误消息:
“你调用的对象是空的。”
我的课:
public sealed class GetListOfServiceIdsToProcess
{
public InOutArgument<IArguments> Arguments { get; set; }
protected override void Execute(CodeActivityContext context)
{
// I am recieving my error exception here
context.GetExtension<lib.Extension.MyExtenstion>();
var targetIds= (List<int>)Settings.Get("targetIds");
var wfa = this.Arguments.Get(context);
wfa.ListTargetIds = targetIds;
Arguments.Set(context, wfa);
}
}
到目前为止我的测试:
据我所知,我对测试的实施有疑问:
/// <summary>
///A test for Execute
///</summary>
[TestMethod()]
public void ExecuteTest()
{
// create Isettings mock to return collection of service ids
var expected = new List<int>() { 30, 20 };
var wfaInput = new TestWorkFlow();
var serviceIdList = new GetListOfServiceIdsToProcess();
var wfParam = new Dictionary<string, object>();
wfParam.Add("WorkFlowArguments", wfaInput);
var results = WorkflowInvoker.Invoke(serviceIdList, wfParam);
var wfaResult = (IWorkFlowArguments)results["WorkFlowArguments"];
Assert.AreEqual(expected, wfaResult.ListOfServiceIdsToProcess);
}