本文整理汇总了C#中Mock.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.Dispose方法的具体用法?C# Mock.Dispose怎么用?C# Mock.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: when_stopping_disposed_then_ignores
public void when_stopping_disposed_then_ignores()
{
var receiver = new Mock<IMessageReceiver>();
var serializer = new Mock<ITextSerializer>();
var processor = new Mock<MessageProcessor>(receiver.Object, serializer.Object) { CallBase = true }.Object;
processor.Dispose();
processor.Stop();
}
示例2: when_disposing_then_disposes_receiver_if_disposable
public void when_disposing_then_disposes_receiver_if_disposable()
{
var receiver = new Mock<IMessageReceiver>();
var disposable = receiver.As<IDisposable>();
var serializer = new Mock<ITextSerializer>();
var processor = new Mock<MessageProcessor>(receiver.Object, serializer.Object) { CallBase = true }.Object;
processor.Dispose();
disposable.Verify(x => x.Dispose());
}
示例3: when_disposing_started_then_stops
public void when_disposing_started_then_stops()
{
var receiver = new Mock<IMessageReceiver>();
var serializer = new Mock<ITextSerializer>();
var processor = new Mock<MessageProcessor>(receiver.Object, serializer.Object) { CallBase = true }.Object;
processor.Start();
processor.Dispose();
Mock.Get(processor).Verify(x => x.Stop());
}
示例4: Format
public void Format()
{
var mockMgr = new Mock<IOutputPortMgr>();
var mockInPort = new Mock<IOutputPort>();
var mockEnum = new Mock<IEnumerator<IOutputPort>>();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(mockMgr.Count, 1);
recorder.ExpectAndReturn(mockMgr.GetEnumerator(), mockEnum);
recorder.ExpectAndReturn(mockEnum.MoveNext(), true);
recorder.ExpectAndReturn(mockEnum.Current, mockInPort);
recorder.ExpectAndReturn(mockInPort.ContentType, BlobType.Network);
recorder.ExpectAndReturn(mockInPort.OutputStatus, PayLoadStatus.Available);
recorder.ExpectAndReturn(mockEnum.MoveNext(), false);
mockEnum.Dispose();
}
OutputPortMgrTextFormatter formatter = new OutputPortMgrTextFormatter();
string result = formatter.Format(mockMgr);
Assert.NotNull(result);
MockManager.Verify();
}
示例5: CannotNegotiateUsingFinishedTransport
public void CannotNegotiateUsingFinishedTransport()
{
var transport =
new Mock<ClientTransportBase>(Mock.Of<IHttpClient>(), "fakeTransport") { CallBase = true }.Object;
transport.Dispose();
Assert.Equal(
Resources.Error_TransportCannotBeReused,
Assert.Throws<InvalidOperationException>(
() => transport.Negotiate(Mock.Of<IConnection>(), "connectionData")).Message);
}