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


C# DynamicMock.Verify方法代码示例

本文整理汇总了C#中NMock.DynamicMock.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMock.Verify方法的具体用法?C# DynamicMock.Verify怎么用?C# DynamicMock.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NMock.DynamicMock的用法示例。


在下文中一共展示了DynamicMock.Verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartCruiseServerProject

		public void StartCruiseServerProject()
		{
			ConsoleRunnerArguments consoleArgs = new ConsoleRunnerArguments();
			Mock mockCruiseServer = new DynamicMock(typeof(ICruiseServer));
			mockCruiseServer.Expect("Start");
			mockCruiseServer.Expect("WaitForExit");
			Mock mockCruiseServerFactory = new DynamicMock(typeof(ICruiseServerFactory));
			mockCruiseServerFactory.ExpectAndReturn("Create", mockCruiseServer.MockInstance, consoleArgs.UseRemoting, consoleArgs.ConfigFile);

			new ConsoleRunner(consoleArgs, (ICruiseServerFactory)mockCruiseServerFactory.MockInstance).Run();

			mockCruiseServer.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:13,代码来源:ConsoleRunnerTest.cs

示例2: ViewManagerCreateView

        public void ViewManagerCreateView()
        {
            #region Mock intialization

            DynamicMock useCase = new DynamicMock(typeof(IUseCase));
            DynamicMock engine = new DynamicMock(typeof(IRegexEngine));
            DynamicMock view = new DynamicMock(typeof(IRegexView));

            IRegexView viewMockInstance = (IRegexView)view.MockInstance;
            IUseCase useCaseMockInstance = (IUseCase)useCase.MockInstance;
            IRegexEngine engineMockInstance = (IRegexEngine)engine.MockInstance;

            #endregion

            useCase.ExpectAndReturn("CreateNewView", viewMockInstance);
            useCase.ExpectAndReturn("CreateNewEngine", engineMockInstance);
            engine.Expect("AttachView", withSameObjectAs(viewMockInstance));
            view.Expect("Init", withSameObjectAs(engineMockInstance));

            ViewManager factory = new ViewManager();
            IRegexView newView = factory.CreateView(useCaseMockInstance);

            useCase.Verify();
            engine.Verify();
            view.Verify();

            Assert.AreSame(newView, viewMockInstance,"Returned view is not the same instance as expected");
        }
开发者ID:Nullstr1ng,项目名称:dotnet-regex-tools,代码行数:28,代码来源:ViewFactoryTests.cs

示例3: SetupAndTeardownRemotingInfrastructure

		public void SetupAndTeardownRemotingInfrastructure()
		{
			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");

			using (new RemoteCruiseServer((ICruiseServer) mockCruiseServer.MockInstance, configFile))
			{
				Assert.AreEqual(2, ChannelServices.RegisteredChannels.Length);
				Assert.IsNotNull(ChannelServices.GetChannel("ccnet"), "ccnet channel is missing");
				Assert.IsNotNull(ChannelServices.GetChannel("ccnet2"), "ccnet2 channel is missing");

				ICruiseManager remoteManager = (ICruiseManager) RemotingServices.Connect(typeof (ICruiseManager), "tcp://localhost:35354/" + RemoteCruiseServer.ManagerUri);
				Assert.IsNotNull(remoteManager, "cruiseserver should be registered on tcp channel");

				remoteManager = (ICruiseManager) RemotingServices.Connect(typeof (ICruiseManager), "http://localhost:35355/" + RemoteCruiseServer.ManagerUri);
				Assert.IsNotNull(remoteManager, "cruiseserver should be registered on http channel");
			}
			Assert.AreEqual(0, ChannelServices.RegisteredChannels.Length, "all registered channels should be closed.");
			mockCruiseServer.Verify();
			mockCruiseManager.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:26,代码来源:RemoteCruiseServerTest.cs

示例4: ShouldBeAbleToSaveProjectsThatALoaderCanLoad

		public void ShouldBeAbleToSaveProjectsThatALoaderCanLoad()
		{
			ExecutableTask builder = new ExecutableTask();
			builder.Executable = "foo";
			FileSourceControl sourceControl = new FileSourceControl();
			sourceControl.RepositoryRoot = "bar";
			// Setup
			Project project1 = new Project();
			project1.Name = "Project One";
			project1.SourceControl = sourceControl;
			Project project2 = new Project();
			project2.Name = "Project Two";
			project2.SourceControl = sourceControl;
			ProjectList projectList = new ProjectList();
			projectList.Add(project1);
			projectList.Add(project2);

			DynamicMock mockConfiguration = new DynamicMock(typeof(IConfiguration));
			mockConfiguration.ExpectAndReturn("Projects", projectList);

			FileInfo configFile = new FileInfo(TempFileUtil.CreateTempFile(TempFileUtil.CreateTempDir(this), "loadernet.config"));

			// Execute
			DefaultConfigurationFileSaver saver = new DefaultConfigurationFileSaver(new NetReflectorProjectSerializer());
			saver.Save((IConfiguration) mockConfiguration.MockInstance, configFile);

			DefaultConfigurationFileLoader loader = new DefaultConfigurationFileLoader();
			IConfiguration configuration2 = loader.Load(configFile);

			// Verify
			Assert.IsNotNull (configuration2.Projects["Project One"]);
			Assert.IsNotNull (configuration2.Projects["Project Two"]);
			mockConfiguration.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:34,代码来源:ConfigurationFileSaverTest.cs

示例5: 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

示例6: ShouldUseBuildLogTransformerToGenerateView

		public void ShouldUseBuildLogTransformerToGenerateView()
		{
			DynamicMock buildLogTransformerMock = new DynamicMock(typeof(IBuildLogTransformer));
			DynamicMock cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest));
			DynamicMock buildSpecifierMock = new DynamicMock(typeof(IBuildSpecifier));
			DynamicMock requestStub = new DynamicMock(typeof(IRequest));

			ICruiseRequest cruiseRequest = (ICruiseRequest) cruiseRequestMock.MockInstance;
			IBuildSpecifier buildSpecifier = (IBuildSpecifier) buildSpecifierMock.MockInstance;
			IRequest request = (IRequest) requestStub.MockInstance;

			cruiseRequestMock.ExpectAndReturn("BuildSpecifier", buildSpecifier);
			cruiseRequestMock.SetupResult("Request", request);
			requestStub.SetupResult("ApplicationPath", "myAppPath");
			Hashtable expectedXsltArgs = new Hashtable();
			expectedXsltArgs["applicationPath"] = "myAppPath";
			buildLogTransformerMock.ExpectAndReturn("Transform", "transformed", buildSpecifier, new string[] { @"xsl\myxsl.xsl" }, new HashtableConstraint(expectedXsltArgs), null);

			XslReportBuildAction action = new XslReportBuildAction((IBuildLogTransformer) buildLogTransformerMock.MockInstance, null);
			action.XslFileName = @"xsl\myxsl.xsl";

			Assert.AreEqual("transformed", ((HtmlFragmentResponse)action.Execute(cruiseRequest)).ResponseFragment);

			buildLogTransformerMock.Verify();
			cruiseRequestMock.Verify();
			buildSpecifierMock.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:27,代码来源:XslReportActionTest.cs

示例7: 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

示例8: InvalidPortName

 public void InvalidPortName()
 {
     Mock source = new DynamicMock(typeof(IUnmanagedSource));
     source.ExpectAndReturn("CreateFile", new IntPtr(2), null, null, null, null, null, null, null, null);
     source.ExpectAndReturn("GetFileType", FileType.Disk, new IntPtr(2));
     UnmanagedProvider.Source = (IUnmanagedSource) source.MockInstance;
     new PortStream("xpto");
     source.Verify();
 }
开发者ID:davidajulio,项目名称:hx,代码行数:9,代码来源:TestPortStream.cs

示例9: 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

示例10: 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

示例11: DefaultPowerShellShouldBe2IfInstalled

        public void DefaultPowerShellShouldBe2IfInstalled()
        {
            IMock mockRegistry2 = new DynamicMock(typeof(IRegistry));

            PowerShellTask task = new PowerShellTask((IRegistry)mockRegistry2.MockInstance, (ProcessExecutor)mockProcessExecutor.MockInstance);
            mockRegistry2.ExpectAndReturn("GetLocalMachineSubKeyValue", POWERSHELL2_PATH,
                                        PowerShellTask.regkeypowershell2,PowerShellTask.regkeyholder);
            Assert.AreEqual(POWERSHELL2_PATH + "\\powershell.exe", task.Executable);
            mockRegistry2.Verify();
            mockProcessExecutor.Verify();
        }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:11,代码来源:PowerShellTaskTest.cs

示例12: ShouldUseObjectGiverToInstantiateActions

		public void ShouldUseObjectGiverToInstantiateActions()
		{
			DynamicMock objectSourceMock = new DynamicMock(typeof(ObjectSource));
			Type typeToInstantiate = typeof(XslReportBuildAction);
			ICruiseAction instantiated = new XslReportBuildAction(null, null);
			objectSourceMock.ExpectAndReturn("GetByType", instantiated, typeToInstantiate);

			ActionInstantiatorWithObjectSource instantiator = new ActionInstantiatorWithObjectSource((ObjectSource) objectSourceMock.MockInstance);
			Assert.AreEqual(instantiated, instantiator.InstantiateAction(typeToInstantiate));
			objectSourceMock.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:11,代码来源:ActionInstantiatorWithObjectGiverTest.cs

示例13: ShouldDelegateForEachFileAndSeparateWithLineBreaks

		public void ShouldDelegateForEachFileAndSeparateWithLineBreaks()
		{
			DynamicMock delegateMock = new DynamicMock(typeof(ITransformer));
			HtmlAwareMultiTransformer transformer = new HtmlAwareMultiTransformer((ITransformer) delegateMock.MockInstance);

			string input = "myinput";

			delegateMock.ExpectAndReturn("Transform", @"<p>MyFirstOutput<p>",  input, "xslFile1", null);
			delegateMock.ExpectAndReturn("Transform", @"<p>MySecondOutput<p>",  input, "xslFile2", null);

			Assert.AreEqual(@"<p>MyFirstOutput<p><p>MySecondOutput<p>", transformer.Transform(input, new string[] { "xslFile1", "xslFile2" }, null));
			delegateMock.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:13,代码来源:HtmlAwareMultiTransformerTest.cs

示例14: ShouldDelegateExtensionToSubBuilder

		public void ShouldDelegateExtensionToSubBuilder()
		{
			// Setup
			DynamicMock decoratedBuilderMock = new DynamicMock(typeof(IUrlBuilder));
			decoratedBuilderMock.ExpectAndReturn("Extension", "foo");

			// Execute
			AbsolutePathUrlBuilderDecorator decorator = new AbsolutePathUrlBuilderDecorator((IUrlBuilder) decoratedBuilderMock.MockInstance, null);
			decorator.Extension = "foo";

			// Verify
			decoratedBuilderMock.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:13,代码来源:AbsolutePathUrlBuilderDecoratorTest.cs

示例15: ShouldGetSourceIfAutoGetSourceTrue

		public void ShouldGetSourceIfAutoGetSourceTrue()
		{
			DynamicMock executor = new DynamicMock(typeof(ProcessExecutor));
			AccuRev accurev = new AccuRev((ProcessExecutor) executor.MockInstance);
			accurev.AutoGetSource = true;

			ProcessInfo expectedProcessRequest = new ProcessInfo("accurev.exe", "update");
			expectedProcessRequest.TimeOut = Timeout.DefaultTimeout.Millis;

			executor.ExpectAndReturn("Execute", new ProcessResult("foo", null, 0, false), expectedProcessRequest);
			accurev.GetSource(new IntegrationResult());
			executor.Verify();
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:13,代码来源:AccuRevTest.cs


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