本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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();
}
示例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");
}
示例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 });
}
示例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" };
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}