本文整理汇总了C#中NMock.DynamicMock.ExpectNoCall方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMock.ExpectNoCall方法的具体用法?C# DynamicMock.ExpectNoCall怎么用?C# DynamicMock.ExpectNoCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NMock.DynamicMock
的用法示例。
在下文中一共展示了DynamicMock.ExpectNoCall方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldOnlyAllowOneThreadToResolveEachType
public void ShouldOnlyAllowOneThreadToResolveEachType()
{
TypeToTypeMap sharedMap = new HashtableTypeMap(Hashtable.Synchronized(new Hashtable()));
DynamicMock expectedToBeUsed = new DynamicMock(typeof(ImplementationResolver));
expectedToBeUsed.ExpectAndReturn("ResolveImplementation", typeof(TestClass), typeof(TestInterface));
DynamicMock notExpectedToBeUsed = new DynamicMock(typeof(ImplementationResolver));
notExpectedToBeUsed.ExpectNoCall("ResolveImplementation", typeof(Type));
StallingImplementationResolver stallingResolver = new StallingImplementationResolver((ImplementationResolver) expectedToBeUsed.MockInstance);
ImplementationResolver resolvingResolver = new CachingImplementationResolver(
stallingResolver, sharedMap);
ImplementationResolver moochingResolver = new CachingImplementationResolver((ImplementationResolver) notExpectedToBeUsed.MockInstance, sharedMap);
ImplementationResolverRunner resolvingRunner = new ImplementationResolverRunner(resolvingResolver, typeof(TestInterface));
Thread resolvingThread = new Thread(
new ThreadStart(resolvingRunner.runResolution));
ImplementationResolverRunner moochingRunner = new ImplementationResolverRunner(moochingResolver, typeof(TestInterface));
Thread moochingThread = new Thread(
new ThreadStart(moochingRunner.runResolution));
resolvingThread.Start();
moochingThread.Start();
Thread.Sleep(500); // allow moochingThread to catch up to resolvingThread
stallingResolver.Resume();
Assert.IsTrue(resolvingThread.Join(200), "Resolving thread did not complete before timeout.");
Assert.IsTrue(moochingThread.Join(200), "Mooching thread did not complete before timeout.");
expectedToBeUsed.Verify();
notExpectedToBeUsed.Verify();
Assert.AreEqual(typeof(TestClass), resolvingRunner.implementationType);
Assert.AreEqual(typeof(TestClass), moochingRunner.implementationType);
}
示例2: NullPortThrowsException
public void NullPortThrowsException()
{
Mock source = new DynamicMock(typeof(IUnmanagedSource));
source.ExpectNoCall("CreateFile", null, null, null, null, null, null, null);
UnmanagedProvider.Source = (IUnmanagedSource) source.MockInstance;
new PortStream(null);
source.Verify();
}
示例3: ShouldNotGetSourceIfAutoGetSourceFalse
public void ShouldNotGetSourceIfAutoGetSourceFalse()
{
DynamicMock executor = new DynamicMock(typeof(ProcessExecutor));
AccuRev accurev = new AccuRev((ProcessExecutor) executor.MockInstance);
accurev.AutoGetSource = false;
executor.ExpectNoCall("Execute", typeof(ProcessInfo));
accurev.GetSource(new IntegrationResult());
executor.Verify();
}
示例4: NoPermissionToUnmanaged
public void NoPermissionToUnmanaged()
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Deny();
Mock handleMock = new DynamicMock(typeof(IUnmanagedSource));
handleMock.ExpectNoCall("CreateFile", null, null, null, null, null, null, null);
UnmanagedProvider.Source = (IUnmanagedSource) handleMock.MockInstance;
new PortStream("COM1");
handleMock.Verify();
SecurityPermission.RevertDeny();
}
示例5: ShouldOnlyDisposeOnce
public void ShouldOnlyDisposeOnce()
{
string configFile = CreateTemporaryConfigurationFile();
IMock mockCruiseManager = new RemotingMock(typeof (ICruiseManager));
IMock mockCruiseServer = new DynamicMock(typeof (ICruiseServer));
mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
mockCruiseServer.Expect("Dispose");
RemoteCruiseServer server = new RemoteCruiseServer((ICruiseServer) mockCruiseServer.MockInstance, configFile);
((IDisposable)server).Dispose();
mockCruiseServer.ExpectNoCall("Dispose");
((IDisposable)server).Dispose();
mockCruiseServer.Verify();
}
示例6: ShowHelp
public void ShowHelp()
{
ConsoleRunnerArguments consoleArgs = new ConsoleRunnerArguments();
consoleArgs.UseRemoting = true;
consoleArgs.ShowHelp = true;
Mock mockCruiseServerFactory = new DynamicMock(typeof(ICruiseServerFactory));
mockCruiseServerFactory.ExpectNoCall("Create", typeof(bool), typeof(string));
ConsoleRunner runner = new ConsoleRunner(consoleArgs, (ICruiseServerFactory)mockCruiseServerFactory.MockInstance);
runner.Run();
// FIXME: should we care for the usage text and the logging implementation?
// If yes read it from the embedded resource
//Assert.AreEqual(1, listener.Traces.Count);
//Assert.IsTrue(listener.Traces[0].ToString().IndexOf(ConsoleRunnerArguments.Usage) > 0, "Wrong message was logged.");
mockCruiseServerFactory.Verify();
}
示例7: ShouldNotGetSourceIfAutoGetSourceFalse
public void ShouldNotGetSourceIfAutoGetSourceFalse()
{
DynamicMock executor = new DynamicMock(typeof(ProcessExecutor));
ExternalSourceControl externalSC = new ExternalSourceControl((ProcessExecutor)executor.MockInstance);
externalSC.AutoGetSource = false;
executor.ExpectNoCall("Execute", typeof(ProcessInfo));
externalSC.GetSource(new IntegrationResult());
executor.Verify();
}
示例8: ShouldStopBuildIfTaskFails
public void ShouldStopBuildIfTaskFails()
{
IntegrationResult result = IntegrationResultMother.CreateFailed();
mockTask.Expect("Run", result);
IMock secondTask = new DynamicMock(typeof (ITask));
secondTask.ExpectNoCall("Run", typeof (IntegrationResult));
project.Tasks = new ITask[] {(ITask) mockTask.MockInstance, (ITask) secondTask.MockInstance};
project.Run(result);
VerifyAll();
secondTask.Verify();
}
示例9: IfRequireChangesFromAllTrueAndFirstSourceControlHasEmptyChangesThenReturnEmpty
public void IfRequireChangesFromAllTrueAndFirstSourceControlHasEmptyChangesThenReturnEmpty()
{
//// SETUP
IntegrationResult from = IntegrationResultMother.CreateSuccessful(DateTime.Now);
IntegrationResult to = IntegrationResultMother.CreateSuccessful(DateTime.Now.AddDays(10));
Modification mod1 = new Modification();
mod1.Comment = "Testing Multi";
ArrayList mocks = new ArrayList();
mocks.Add(CreateModificationsSourceControlMock(new Modification[0], from, to));
DynamicMock nonCalledMock = new DynamicMock(typeof (ISourceControl));
nonCalledMock.ExpectNoCall("GetModifications", typeof(IIntegrationResult), typeof(IIntegrationResult));
mocks.Add(nonCalledMock);
ArrayList scList = new ArrayList();
foreach (DynamicMock mock in mocks)
{
scList.Add(mock.MockInstance);
}
MultiSourceControl multiSourceControl = new MultiSourceControl();
multiSourceControl.SourceControls = (ISourceControl[]) scList.ToArray(typeof (ISourceControl));
multiSourceControl.RequireChangesFromAll = true;
//// EXECUTE
ArrayList returnedMods = new ArrayList(multiSourceControl.GetModifications(from, to));
//// VERIFY
foreach (DynamicMock mock in mocks)
{
mock.Verify();
}
Assert.AreEqual(0, returnedMods.Count);
}
示例10: ShouldNotGetSourceIfAutoGetSourceFalse
public void ShouldNotGetSourceIfAutoGetSourceFalse()
{
DynamicMock executor = new DynamicMock(typeof(ProcessExecutor));
ClearCase clearCase = new ClearCase((ProcessExecutor) executor.MockInstance);
clearCase.Executable = EXECUTABLE;
clearCase.ViewPath = VIEWPATH;
clearCase.AutoGetSource = false;
executor.ExpectNoCall("Execute", typeof(ProcessInfo));
clearCase.GetSource(new IntegrationResult());
executor.Verify();
}