当前位置: 首页>>代码示例>>C#>>正文


C# DynamicMock.ExpectNoCall方法代码示例

本文整理汇总了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);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:35,代码来源:CachingImplementationResolverTest.cs

示例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();
 }
开发者ID:davidajulio,项目名称:hx,代码行数:8,代码来源:TestPortStream.cs

示例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();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:10,代码来源:AccuRevTest.cs

示例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();
 }
开发者ID:davidajulio,项目名称:hx,代码行数:10,代码来源:TestPortStream.cs

示例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();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:16,代码来源:RemoteCruiseServerTest.cs

示例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();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:19,代码来源:ConsoleRunnerTest.cs

示例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();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:10,代码来源:ExternalSourceControlTest.cs

示例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();
		}
开发者ID:kyght,项目名称:CruiseControl.NET,代码行数:13,代码来源:ProjectTest.cs

示例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);
		}
开发者ID:RubenWillems,项目名称:CruiseControl.NET,代码行数:36,代码来源:MultiSourceControlTest.cs

示例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();
        }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:12,代码来源:ClearCaseTest.cs


注:本文中的NMock.DynamicMock.ExpectNoCall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。