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


C# DynamicMock.Expect方法代码示例

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


在下文中一共展示了DynamicMock.Expect方法的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: KillContainer

		public void KillContainer()
		{
			Mock mockPicoContainer = new DynamicMock(typeof(IMutablePicoContainer));
			IMutablePicoContainer picoContainer = mockPicoContainer.MockInstance as IMutablePicoContainer;
			mockPicoContainer.Expect("Stop");
			mockPicoContainer.Expect("Dispose");
			mockPicoContainer.ExpectAndReturn("Parent", new DefaultPicoContainer(picoContainer));
			mockPicoContainer.Strict = true;

			LifeCycleContainerBuilder lifeCycleContainerBuilder = new StubLifeCycleContainerBuilder();
			SimpleReference reference = new SimpleReference();
			reference.Set(mockPicoContainer.MockInstance);

			lifeCycleContainerBuilder.KillContainer(reference);
			mockPicoContainer.Verify();
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:16,代码来源:LifeCycleContainerBuilderTestCase.cs

示例3: TestSimpleSmtpNegotiation

		public void TestSimpleSmtpNegotiation()
		{
			SmtpServer smtpserver=new SmtpServer("localhost");
			EmailMessage emailMessage=GetTestHtmlAndTextMessage();

			IMock mockSmtpProxy = new DynamicMock(typeof(ISmtpProxy));
			mockSmtpProxy.ExpectAndReturn("Open", new SmtpResponse(220, "welcome to the mock object server"), null);
			mockSmtpProxy.ExpectAndReturn("Helo", new SmtpResponse(250, "helo"), Dns.GetHostName());
			mockSmtpProxy.ExpectAndReturn("MailFrom", new SmtpResponse(250, "mail from"), emailMessage.FromAddress);
			foreach (EmailAddress rcpttoaddr in emailMessage.ToAddresses) 
			{
				mockSmtpProxy.ExpectAndReturn("RcptTo", new SmtpResponse(250, "receipt to"), rcpttoaddr);
			}
			mockSmtpProxy.ExpectAndReturn("Data", new SmtpResponse(354, "data open"), null);
			mockSmtpProxy.ExpectAndReturn("WriteData", new SmtpResponse(250, "data"), emailMessage.ToDataString());
			
			mockSmtpProxy.ExpectAndReturn("Quit", new SmtpResponse(221, "quit"), null);
			mockSmtpProxy.Expect("Close", null);

			ISmtpProxy smtpProxy= (ISmtpProxy) mockSmtpProxy.MockInstance;
			

			smtpserver.OverrideSmtpProxy(smtpProxy);

			
			emailMessage.Send(smtpserver);


		}
开发者ID:dineshkummarc,项目名称:DotNetOpenMail-0.5.8b-src,代码行数:29,代码来源:SmtpServerTests.cs

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

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

示例6: Init

		public void Init()
		{
			m_mock = new DynamicMock(typeof(IIgnoreOrderTest));
			m_mock.Expect("Method",
				new object[] { new IgnoreOrderConstraint(0, 1, 2 )},
				new string[] { typeof(int[]).FullName });
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:7,代码来源:NMockConstraintsTests.cs

示例7: Init

		public void Init()
		{
			m_mock = new DynamicMock(typeof(IIgnoreOrderTest));
			m_mock.Expect("Method",
				new object[] { new IgnoreOrderConstraint(0, 1, 2 )},
				new string[] { typeof(int[]).FullName });
			m_mock.AdditionalReferences = new string[] { "COMInterfacesTests.dll" };
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:8,代码来源:NMockConstraintsTests.cs

示例8: PublishersShouldBeTasks

		public void PublishersShouldBeTasks()
		{
			IMock mock = new DynamicMock(typeof (ITask));
			IntegrationResult result = new IntegrationResult();
			mock.Expect("Run", result);

			ITask publisher = (ITask) mock.MockInstance;
			publisher.Run(result);
		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:9,代码来源:PublisherTest.cs

示例9: MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor

		public void MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor()
		{
			DynamicMock mockProjectMonitor = new DynamicMock(typeof (IProjectMonitor));

			SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
				(IProjectMonitor) mockProjectMonitor.MockInstance, null);

			mockProjectMonitor.ExpectAndReturn("ProjectState", null);
			Assert.IsNull(monitor.ProjectState);

            Dictionary<string, string> parameters = new Dictionary<string, string>();
			mockProjectMonitor.Expect("ForceBuild", parameters, (string)null);
			monitor.ForceBuild(parameters, null);

			mockProjectMonitor.Expect("Poll");
			monitor.Poll();

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

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

示例11: RunForceBuild

        public void RunForceBuild()
        {
            Workflow project = new Workflow();
            IMock taskMock1 = new DynamicMock(typeof (ITask));
            taskMock1.Expect("Run", new NotNull());

            IMock taskMock2 = new DynamicMock(typeof (ITask));
            taskMock2.Expect("Run", new NotNull());

            project.Tasks.Add(taskMock1.MockInstance);
            project.Tasks.Add(taskMock2.MockInstance);

            project.Integrate(ForceBuildRequest());

            taskMock1.Verify();
            taskMock2.Verify();
        }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:17,代码来源:WorkflowTest.cs

示例12: WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke

		public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
		{
			DynamicMock mockSynchronizeInvoke = new DynamicMock(typeof (ISynchronizeInvoke));
			StubServerMonitor containedMonitor = new StubServerMonitor(@"tcp://blah/");

			SynchronizedServerMonitor monitor = new SynchronizedServerMonitor(
				containedMonitor,
				(ISynchronizeInvoke) mockSynchronizeInvoke.MockInstance);

			MonitorServerQueueChangedEventHandler delegateToQueueChanged = new MonitorServerQueueChangedEventHandler(Monitor_QueueChanged);
			monitor.QueueChanged += delegateToQueueChanged;

			mockSynchronizeInvoke.Expect("BeginInvoke", delegateToQueueChanged, new IsTypeOf(typeof (object[])));
			containedMonitor.OnQueueChanged(new MonitorServerQueueChangedEventArgs(null));

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

示例13: WhenPolledIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke

		public void WhenPolledIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
		{
			DynamicMock mockSynchronizeInvoke = new DynamicMock(typeof (ISynchronizeInvoke));
			StubProjectMonitor containedMonitor = new StubProjectMonitor("test");

			SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
				containedMonitor,
				(ISynchronizeInvoke) mockSynchronizeInvoke.MockInstance);

			MonitorPolledEventHandler delegateToPolledMethod = new MonitorPolledEventHandler(Monitor_Polled);
			monitor.Polled += delegateToPolledMethod;

			mockSynchronizeInvoke.Expect("BeginInvoke", delegateToPolledMethod, new IsTypeOf(typeof (object[])));
			containedMonitor.OnPolled(new MonitorPolledEventArgs(containedMonitor));

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

示例14: WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke

		public void WhenBuildOccurredIsFiredTheDelegateIsInvokedThroughISynchronisedInvoke()
		{
			DynamicMock mockSynchronizeInvoke = new DynamicMock(typeof (ISynchronizeInvoke));
			StubProjectMonitor containedMonitor = new StubProjectMonitor("test");

			SynchronizedProjectMonitor monitor = new SynchronizedProjectMonitor(
				containedMonitor,
				(ISynchronizeInvoke) mockSynchronizeInvoke.MockInstance);

			MonitorBuildOccurredEventHandler delegateToBuildOccurred = new MonitorBuildOccurredEventHandler(Monitor_BuildOccurred);
			monitor.BuildOccurred += delegateToBuildOccurred;

			mockSynchronizeInvoke.Expect("BeginInvoke", delegateToBuildOccurred, new IsTypeOf(typeof (object[])));
			containedMonitor.OnBuildOccurred(new MonitorBuildOccurredEventArgs(null, BuildTransition.StillFailing));

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

示例15: MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor

		public void MethodsAndPropertiesDoSimpleDelagationOntoInjectedMonitor()
		{
			DynamicMock mockServerMonitor = new DynamicMock(typeof (ISingleServerMonitor));

			SynchronizedServerMonitor monitor = new SynchronizedServerMonitor(
				(ISingleServerMonitor) mockServerMonitor.MockInstance, null);

			mockServerMonitor.ExpectAndReturn("ServerUrl", @"tcp://blah/");
			Assert.AreEqual(@"tcp://blah/", monitor.ServerUrl);

			mockServerMonitor.ExpectAndReturn("IsConnected", true);
			Assert.AreEqual(true, monitor.IsConnected);

			mockServerMonitor.Expect("Poll");
			monitor.Poll();

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


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