本文整理汇总了C#中Mock.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.Execute方法的具体用法?C# Mock.Execute怎么用?C# Mock.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteMethodChangesElementStatusBeforeExecutingTheFxGroup
public void ExecuteMethodChangesElementStatusBeforeExecutingTheFxGroup()
{
ISetParamMgr setterParamMgr = _element as ISetParamMgr;
ISetPortMgrs setterPortsMgr = _element as ISetPortMgrs;
ISetSimpleFx setterFx = _element as ISetSimpleFx;
ValidationResults results1 = null;
ValidationResults results2 = null;
var mockParamMgr = new Mock<IIdentNodeCoresParamMgr>();
var mockInPortMgr = new Mock<IInputPortMgr>();
var mockOutPortMgr = new Mock<IOutputPortMgr>();
var mockFx = new Mock<IIdentNodeCoresFx>();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.DefaultBehavior.Strict = StrictFlags.ArbitraryMethodsAllowed;
recorder.ExpectAndReturn(_element.OutPortMgr, mockOutPortMgr).RepeatAlways();
recorder.ExpectAndReturn(mockOutPortMgr.PortStatuses, null).RepeatAlways();
recorder.ExpectAndReturn(mockInPortMgr.Validate(out results1), true);
recorder.ExpectAndReturn(mockParamMgr.Validate(out results2), true);
mockFx.Execute(null, null, null, null);
(_element as SimpleElementBase).Log(LogReasons.Start, null, null);
}
ElementStatus initialStatus = _element.Status;
setterPortsMgr.SetInputMgr(mockInPortMgr);
setterParamMgr.SetMgr(mockParamMgr);
setterFx.SetFxGroup(mockFx);
_element.Execute();
ElementStatus expectedStatus = _element.Status;
MockManager.Verify();
Assert.Equal(ElementStatus.Incomplete, initialStatus);
Assert.Equal(ElementStatus.Executing, expectedStatus);
}
示例2: Execute_Func_throws_on_null_parameters
public void Execute_Func_throws_on_null_parameters()
{
var mockExecutionStrategy =
new Mock<DbExecutionStrategy>
{
CallBase = true
}.Object;
Assert.Equal(
"operation",
Assert.Throws<ArgumentNullException>(() => mockExecutionStrategy.Execute((Func<int>)null)).ParamName);
}
示例3: Execute_WhenStatusIsComplete
public void Execute_WhenStatusIsComplete()
{
var mockEl = new Mock<DummyCompoundElement>();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(mockEl.Status, ElementStatus.Complete).Repeat(2);
mockEl.ResetWithNotification(false);
mockEl.ExecutionProper();
}
mockEl.Execute();
MockManager.Verify();
}
示例4: Execute_Action_throws_on_null_parameters
public void Execute_Action_throws_on_null_parameters()
{
var mockExecutionStrategy =
new Mock<ExecutionStrategyBase>
{
CallBase = true
}.Object;
Assert.Equal(
"action",
Assert.Throws<ArgumentNullException>(() => mockExecutionStrategy.Execute(null)).ParamName);
}
示例5: Execute_WhenStatusIsValidating
public void Execute_WhenStatusIsValidating()
{
var mockEl = new Mock<DummyCompoundElement>();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(mockEl.Status, ElementStatus.Validating).Repeat(4);
mockEl.Cancel();
mockEl.ExecutionProper();
}
mockEl.Execute();
MockManager.Verify();
}