本文整理汇总了C#中Mock.ResetCalls方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.ResetCalls方法的具体用法?C# Mock.ResetCalls怎么用?C# Mock.ResetCalls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.ResetCalls方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Arrange
protected void Arrange()
{
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Loose);
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
_sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
_connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth"));
_operationTimeout = TimeSpan.FromSeconds(new Random().Next(1, 10));
_sftpClient = new SftpClient(_connectionInfo, false, _serviceFactoryMock.Object);
_sftpClient.OperationTimeout = _operationTimeout;
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_serviceFactoryMock.Setup(p => p.CreateSftpSession(_sessionMock.Object, _operationTimeout, _connectionInfo.Encoding))
.Returns(_sftpSessionMock.Object);
_sftpSessionMock.Setup(p => p.Connect());
_sftpClient.Connect();
_sftpClient = null;
_serviceFactoryMock.Setup(p => p.CreateSftpSession(_sessionMock.Object, _operationTimeout, _connectionInfo.Encoding))
.Returns((ISftpSession) null);
_serviceFactoryMock.ResetCalls();
// we need to dereference all other mocks as they might otherwise hold the target alive
_sessionMock = null;
_connectionInfo = null;
_serviceFactoryMock = null;
}
示例2: OnceDoesNotThrowOnSecondCallIfCountWasResetBefore
public void OnceDoesNotThrowOnSecondCallIfCountWasResetBefore()
{
var mock = new Mock<IFooReset>();
mock.Setup(foo => foo.Execute("ping")).Returns("ack");
mock.Object.Execute("ping");
mock.ResetCalls();
mock.Object.Execute("ping");
mock.Verify(o => o.Execute("ping"), Times.Once());
}
示例3: sortFunction_is_not_called_after_a_mapping_is_removed
public void sortFunction_is_not_called_after_a_mapping_is_removed()
{
Mock<IComparer<ICommandMapping>> priorityComparer = new Mock<IComparer<ICommandMapping>> ();
priorityComparer.Setup (c => c.Compare (It.IsAny<ICommandMapping> (), It.IsAny<ICommandMapping> ())).Returns (0);
subject.WithSortFunction (priorityComparer.Object);
addPriorityMappings();
subject.GetList();
priorityComparer.ResetCalls ();
subject.RemoveMappingFor(typeof(NullCommand));
subject.GetList();
priorityComparer.Verify (c => c.Compare (It.IsAny<ICommandMapping> (), It.IsAny<ICommandMapping> ()), Times.Never);
}
示例4: sortFunction_is_only_called_once_after_mappings_are_added
public void sortFunction_is_only_called_once_after_mappings_are_added()
{
Mock<IComparer<ICommandMapping>> priorityComparer = new Mock<IComparer<ICommandMapping>> ();
priorityComparer.Setup (c => c.Compare (It.IsAny<ICommandMapping> (), It.IsAny<ICommandMapping> ())).Returns (0);
subject.WithSortFunction (priorityComparer.Object);
addPriorityMappings();
subject.GetList();
// Reset Times.count to zero
priorityComparer.ResetCalls ();
subject.GetList();
priorityComparer.Verify (c => c.Compare (It.IsAny<ICommandMapping> (), It.IsAny<ICommandMapping> ()), Times.Never);
}
示例5: TestWriteWithCustomHandler
public void TestWriteWithCustomHandler()
{
Mock<IWriteHandler> mock = new Mock<IWriteHandler>();
mock.Setup(m => m.Tag(It.IsAny<object>())).Returns("s");
mock.Setup(m => m.Representation(It.IsAny<object>())).Returns("NULL");
mock.Setup(m => m.StringRepresentation(It.IsAny<object>())).Returns<string>(null);
mock.Setup(m => m.GetVerboseHandler()).Returns<IWriteHandler>(null);
IDictionary<Type, IWriteHandler> customHandlers = new Dictionary<Type, IWriteHandler>();
customHandlers.Add(typeof(NullType), mock.Object);
// JSON-Verbose
Assert.AreEqual(ScalarVerbose("\"NULL\""), WriteJsonVerbose(null, customHandlers));
mock.Verify(m => m.Representation(null));
mock.Verify(m => m.GetVerboseHandler());
// JSON
mock.ResetCalls();
Assert.AreEqual(Scalar("\"NULL\""), WriteJson(null, customHandlers));
mock.Verify(m => m.Representation(null));
}
示例6: TestMultiplayerCamerasConfig
public void TestMultiplayerCamerasConfig()
{
TimelineEvent evt1;
List<CameraConfig> cams1, cams2;
Mock<IMultiPlayer> multiplayerMock = new Mock<IMultiPlayer> ();
mtkMock.Setup (m => m.GetMultiPlayer ()).Returns (multiplayerMock.Object);
player = new PlayerController (true);
PreparePlayer ();
/* Only called internally in the openning */
cams1 = new List<CameraConfig> { new CameraConfig (0), new CameraConfig (1) };
cams2 = new List<CameraConfig> { new CameraConfig (1), new CameraConfig (0) };
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Never ());
Assert.AreEqual (cams1, player.CamerasConfig);
player.CamerasConfig = cams2;
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (cams2, player.CamerasConfig);
multiplayerMock.ResetCalls ();
/* Now load an event */
evt1 = new TimelineEvent { Start = new Time (100), Stop = new Time (200),
CamerasConfig = new List<CameraConfig> { new CameraConfig (1), new CameraConfig (1) }
};
player.LoadEvent (mfs, evt1, evt1.Start, true);
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (evt1.CamerasConfig, player.CamerasConfig);
multiplayerMock.ResetCalls ();
/* Change event cams config */
player.CamerasConfig = new List<CameraConfig> { new CameraConfig (0), new CameraConfig (0) };
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (new List<CameraConfig> { new CameraConfig (0), new CameraConfig (0) }, evt1.CamerasConfig);
Assert.AreEqual (player.CamerasConfig, evt1.CamerasConfig);
multiplayerMock.ResetCalls ();
/* Unload and check the original cams config is set back*/
player.UnloadCurrentEvent ();
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (cams2, player.CamerasConfig);
Assert.AreEqual (new List<CameraConfig> { new CameraConfig (0), new CameraConfig (0) }, evt1.CamerasConfig);
multiplayerMock.ResetCalls ();
/* And changing the config does not affects the unloaded event */
player.CamerasConfig = cams1;
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (new List<CameraConfig> { new CameraConfig (0), new CameraConfig (0) }, evt1.CamerasConfig);
multiplayerMock.ResetCalls ();
/* Now load a playlist video */
PlaylistVideo plv = new PlaylistVideo (mfs [0]);
player.LoadPlaylistEvent (playlist, plv);
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Never ());
Assert.AreEqual (new List<CameraConfig> { new CameraConfig (0) }, player.CamerasConfig);
multiplayerMock.ResetCalls ();
player.UnloadCurrentEvent ();
/* Called by Open internally () */
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Never ());
Assert.AreEqual (cams2, player.CamerasConfig);
multiplayerMock.ResetCalls ();
/* Now load a playlist event and make sure its config is loaded
* and not the event's one */
PlaylistPlayElement ple = new PlaylistPlayElement (evt, mfs);
ple.CamerasConfig = cams2;
player.LoadPlaylistEvent (playlist, ple);
multiplayerMock.Verify (p => p.ApplyCamerasConfig (), Times.Once ());
Assert.AreEqual (cams2, player.CamerasConfig);
multiplayerMock.ResetCalls ();
}
示例7: IsAllowing_WhenAlreadyTripped_DoesntReTripBreaker
public void IsAllowing_WhenAlreadyTripped_DoesntReTripBreaker()
{
const long durationMillis = 10000;
var mockMetrics = CreateMockMetricsWithSnapshot(10, 100); // 10 ops, 100% failing.
var stats = new InternallyCountingStats();
var metricEvents = new Mock<IMetricEvents>();
var breaker = new BreakerBuilder(1, 1, "Test") // Trip at 1 op, 1% failing.
.WithMockMetrics(mockMetrics)
.WithWaitMillis(durationMillis)
.WithStats(stats)
.WithMetricEvents(metricEvents.Object)
.Create();
breaker.IsAllowing(); // Trip the breaker.
Assert.Equal(1, stats.ServicesAndStates.Count(ss => ss.Service == "mjolnir breaker Test" && ss.State == "Tripped"));
metricEvents.Verify(m => m.BreakerTripped("Test"));
metricEvents.ResetCalls();
breaker.IsAllowing(); // Make another call, which should bail immediately (and not re-trip).
// Best way to test this right now is to make sure we don't fire a stat for the state change.
Assert.Equal(1, stats.ServicesAndStates.Count(ss => ss.Service == "mjolnir breaker Test" && ss.State == "Tripped"));
metricEvents.Verify(m => m.BreakerTripped(It.IsAny<string>()), Times.Never);
}
示例8: ReturnsAndDoesNothing_WhenNeo4jUrlIsNullOrWhiteSpace
public void ReturnsAndDoesNothing_WhenNeo4jUrlIsNullOrWhiteSpace(string neo4jUrl)
{
var rc = new Mock<IRestClient>();
var vm = new Neo4jConsoleControlViewModel(rc.Object) {Neo4jUrl = neo4jUrl};
rc.ResetCalls();
vm.PostCommand.Execute(null);
rc.Verify(r => r.Execute(It.IsAny<IRestRequest>()), Times.Never);
}
示例9: HandleInput_StartingFromSomeCell_TableViewSelectCellIsCalled
public void HandleInput_StartingFromSomeCell_TableViewSelectCellIsCalled(int rows, int columns, int selectedRow, int selectedColumn,
CommandKeys key, int newRow, int newColumns)
{
var tableViewMock = new Mock<TableViewMock> { CallBase = true };
var table = CreateTableWidget(tableViewMock.Object, rows, columns);
table.SelectCell(selectedRow, selectedColumn);
tableViewMock.ResetCalls();
tableViewMock.Setup(o => o.SetCellSelection(newRow, newColumns, true)).Verifiable();
table.HandleInput(key);
tableViewMock.Verify();
}
示例10: ResetInvalidation
private void ResetInvalidation(Mock<AbstractGraphicComponent> componentMock)
{
componentMock.Object.Draw();
componentMock.ResetCalls();
}