本文整理汇总了C#中NMock.DynamicMock.SetupResult方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMock.SetupResult方法的具体用法?C# DynamicMock.SetupResult怎么用?C# DynamicMock.SetupResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NMock.DynamicMock
的用法示例。
在下文中一共展示了DynamicMock.SetupResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupSelectionForParas
/// ------------------------------------------------------------------------------------
/// <summary>
/// Creates a simulated range selection
/// </summary>
/// <param name="hvoPara1"></param>
/// <param name="hvoPara2"></param>
/// <param name="ichAnchor"></param>
/// <param name="ichEnd"></param>
/// ------------------------------------------------------------------------------------
public void SetupSelectionForParas(int hvoPara1, int hvoPara2, int ichAnchor, int ichEnd)
{
CheckDisposed();
DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));
fakeSelHelper.SetupResult("NumberOfLevels", 1);
SelLevInfo[] topInfo = new SelLevInfo[1];
topInfo[0].tag = StTextTags.kflidParagraphs;
topInfo[0].hvo = hvoPara1;
SelLevInfo[] bottomInfo = new SelLevInfo[1];
bottomInfo[0].tag = StTextTags.kflidParagraphs;
bottomInfo[0].hvo = hvoPara2;
fakeSelHelper.SetupResult("LevelInfo", topInfo);
fakeSelHelper.SetupResult("IchAnchor", ichAnchor);
fakeSelHelper.SetupResult("IchEnd", ichEnd);
fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
SelectionHelper.SelLimitType.End);
fakeSelHelper.SetupResultForParams("GetIch", ichAnchor,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
SelectionHelper.SelLimitType.Bottom);
m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
}
示例2: ShouldReturnBuildPluginLinksRelevantToThisProject
public void ShouldReturnBuildPluginLinksRelevantToThisProject()
{
DynamicMock buildPluginMock1 = new DynamicMock(typeof (IBuildPlugin));
DynamicMock buildPluginMock2 = new DynamicMock(typeof (IBuildPlugin));
DynamicMock buildPluginMock3 = new DynamicMock(typeof (IBuildPlugin));
buildPluginMock1.SetupResult("LinkDescription", "Description 1");
buildPluginMock1.SetupResult("NamedActions", new INamedAction[] {action1});
buildPluginMock1.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier));
buildPluginMock2.SetupResult("LinkDescription", "Description 2");
buildPluginMock2.SetupResult("NamedActions", new INamedAction[] {action2});
buildPluginMock2.SetupResult("IsDisplayedForProject", true, typeof(IProjectSpecifier));
buildPluginMock3.SetupResult("IsDisplayedForProject", false, typeof(IProjectSpecifier));
configurationMock.ExpectAndReturn("BuildPlugins", new IBuildPlugin[]
{
(IBuildPlugin) buildPluginMock1.MockInstance, (IBuildPlugin) buildPluginMock2.MockInstance, (IBuildPlugin) buildPluginMock3.MockInstance
});
linkFactoryMock.ExpectAndReturn("CreateBuildLink", link1, buildSpecifier, "Description 1", "Action Name 1");
linkFactoryMock.ExpectAndReturn("CreateBuildLink", link2, buildSpecifier, "Description 2", "Action Name 2");
IAbsoluteLink[] buildLinks = Plugins.GetBuildPluginLinks(buildSpecifier);
Assert.AreSame(link1, buildLinks[0]);
Assert.AreSame(link2, buildLinks[1]);
Assert.AreEqual(2, buildLinks.Length);
VerifyAll();
}
示例3: NextIsRaining
public void NextIsRaining()
{
IMock random = new DynamicMock(typeof(System.Random));
WeatherRandom weather = new DefaultWeatherRandom((System.Random)random.MockInstance);
random.SetupResult("NextDouble", 0.0);
Assertion.Assert("is raining", weather.NextIsRaining());
random.SetupResult("NextDouble", DefaultWeatherRandom.CHANCE_OF_RAIN);
Assertion.Assert("is not raining", !weather.NextIsRaining());
random.SetupResult("NextDouble", 1.0);
Assertion.Assert("is not raining", !weather.NextIsRaining());
}
示例4: 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();
}
示例5: Setup
public void Setup()
{
ProjectStatusOnServer server = new ProjectStatusOnServer(new ProjectStatus("myProject", IntegrationStatus.Success, DateTime.Now),
new DefaultServerSpecifier("myServer"));
ProjectStatusListAndExceptions statusList = new ProjectStatusListAndExceptions(
new ProjectStatusOnServer[] {
server
}, new CruiseServerException[] {
});
farmServiceMock = new DynamicMock(typeof(IFarmService));
farmServiceMock.SetupResult("GetProjectStatusListAndCaptureExceptions", statusList, typeof(IServerSpecifier), typeof(string));
viewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator));
linkFactoryMock = new DynamicMock(typeof(ILinkFactory));
ServerLocation serverConfig = new ServerLocation();
serverConfig.ServerName = "myServer";
configuration.Servers = new ServerLocation[] {
serverConfig
};
var urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder));
urlBuilderMock.SetupResult("BuildProjectUrl", string.Empty, typeof(string), typeof(IProjectSpecifier));
plugin = new ProjectReportProjectPlugin((IFarmService) farmServiceMock.MockInstance,
(IVelocityViewGenerator) viewGeneratorMock.MockInstance,
(ILinkFactory) linkFactoryMock.MockInstance,
configuration,
(ICruiseUrlBuilder)urlBuilderMock.MockInstance);
cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest));
cruiseRequest = (ICruiseRequest ) cruiseRequestMock.MockInstance;
}
示例6: SetupSelectionInFootnote
/// ------------------------------------------------------------------------------------
/// <summary>
/// Setup the selection in footnote.
/// </summary>
/// <param name="footnote">The footnote.</param>
/// <param name="book">The book.</param>
/// <param name="iBook">The 0-based index of the book.</param>
/// <param name="ichStart">The 0-based starting character index.</param>
/// <param name="ichEnd">The 0-based ending character index.</param>
/// ------------------------------------------------------------------------------------
public void SetupSelectionInFootnote(IStFootnote footnote, IScrBook book,
int iBook, int ichStart, int ichEnd)
{
CheckDisposed();
DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));
fakeSelHelper.SetupResult("GetTextPropId", StTxtParaTags.kflidContents, typeof(SelectionHelper.SelLimitType));
fakeSelHelper.SetupResult("NumberOfLevels", 3);
// Setup the anchor
SelLevInfo[] topInfo = new SelLevInfo[3];
IStTxtPara para = footnote[0];
topInfo[0].tag = StTextTags.kflidParagraphs;
topInfo[0].ihvo = 0; // only one para per footnote allowed
topInfo[0].hvo = para.Hvo;
topInfo[1].tag = ScrBookTags.kflidFootnotes;
topInfo[1].ihvo = footnote.IndexInOwner;
topInfo[1].hvo = footnote.Hvo;
topInfo[2].tag = BookFilter.Tag;
topInfo[2].ihvo = iBook;
topInfo[2].hvo = book.Hvo;
// Setup the end
SelLevInfo[] bottomInfo = new SelLevInfo[3];
for(int i = 0; i < 3; i++)
bottomInfo[i] = topInfo[i];
fakeSelHelper.SetupResult("LevelInfo", topInfo);
fakeSelHelper.SetupResult("IchAnchor", ichStart);
fakeSelHelper.SetupResult("IchEnd", ichEnd);
fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
SelectionHelper.SelLimitType.Anchor);
fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
SelectionHelper.SelLimitType.Bottom);
fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
SelectionHelper.SelLimitType.End);
fakeSelHelper.SetupResultForParams("GetIch", ichStart,
SelectionHelper.SelLimitType.Top);
fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
SelectionHelper.SelLimitType.Bottom);
m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
}
示例7: Setup
public void Setup()
{
viewBuilderMock = new DynamicMock(typeof(IDeleteProjectViewBuilder));
farmServiceMock = new DynamicMock(typeof(IFarmService));
doDeleteProjectAction = new DoDeleteProjectAction((IDeleteProjectViewBuilder) viewBuilderMock.MockInstance, (IFarmService) farmServiceMock.MockInstance);
cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest));
cruiseRequest = (ICruiseRequest) cruiseRequestMock.MockInstance;
requestMock = new DynamicMock(typeof(IRequest));
cruiseRequestMock.SetupResult("Request", requestMock.MockInstance);
}
示例8: SetUp
public void SetUp()
{
mockProjectMonitor = new DynamicMock(typeof (IProjectMonitor));
mockProjectMonitor.Strict = true;
projectMonitor = (IProjectMonitor) mockProjectMonitor.MockInstance;
mockConfiguration = new DynamicMock(typeof (ICCTrayMultiConfiguration));
configuration = (ICCTrayMultiConfiguration) mockConfiguration.MockInstance;
ISingleServerMonitor[] serverMonitors = new ISingleServerMonitor[0];
mockConfiguration.SetupResult("GetServerMonitors", serverMonitors);
mockConfiguration.SetupResult("GetProjectStatusMonitors", new IProjectMonitor[0], typeof(ISingleServerMonitor[]));
mockConfiguration.SetupResult("Icons", new Icons());
mockConfiguration.SetupResult("FixUserName", "John");
GrowlConfiguration growlConfig = new GrowlConfiguration();
mockConfiguration.SetupResult("Growl", growlConfig);
eventCount = 0;
controller = new MainFormController(configuration, null, null);
}
示例9: SetUp
public void SetUp()
{
_authenticationMock = new DynamicMock(typeof(IAuthentication));
_authenticationMock.SetupResult("Identifier", "johndoe");
_sessionMock = new DynamicMock(typeof(ISessionCache));
_manager = new SessionSecurityManager();
_manager.Settings = new IAuthentication[]{
_authenticationMock.MockInstance as IAuthentication
};
_manager.SessionCache = _sessionMock.MockInstance as ISessionCache;
_manager.Initialise();
}
示例10: ShouldAddQuotesToStringFromVersionAssemblyProviderForFingerprintFromDate
public void ShouldAddQuotesToStringFromVersionAssemblyProviderForFingerprintFromDate()
{
string testETag = "test e tag value";
DateTime testDate = new DateTime(2007, 4, 20);
DynamicMock mockVersionProvider = new DynamicMock(typeof(IVersionProvider));
mockVersionProvider.SetupResult("GetVersion", testETag);
ConditionalGetFingerprint testConditionalGetFingerprint =
new FingerprintFactory((IVersionProvider) mockVersionProvider.MockInstance, null).BuildFromDate(testDate);
string expectedETag = "\"" + testETag + "\"";
Assert.AreEqual(expectedETag, testConditionalGetFingerprint.ETag);
}
示例11: Setup
public void Setup()
{
Teardown();
Directory.CreateDirectory("testtemplates");
using (var writer = new StreamWriter(@"testtemplates\testtemplate.vm"))
{
writer.Write("foo is $foo");
writer.Flush();
writer.Close();
}
configurationMock = new DynamicMock(typeof (IConfigureTheTransformer));
configurationMock.SetupResult("TemplateDirectory", "testtemplates");
viewTransformer =
new LazilyInitialisingVelocityTransformer((IConfigureTheTransformer) configurationMock.MockInstance);
}
示例12: ShouldUseVelocityToMergeContextContentsWithTemplate
public void ShouldUseVelocityToMergeContextContentsWithTemplate()
{
Hashtable contextContents = new Hashtable();
contextContents["foo"] = "bar";
DynamicMock pathMapperMock = new DynamicMock(typeof(IPhysicalApplicationPathProvider));
pathMapperMock.SetupResult("GetFullPathFor", Path.Combine(".", "templates"), typeof (string));
DynamicMock pluginsMock = new DynamicMock(typeof(IPluginConfiguration));
pluginsMock.SetupResult("TemplateLocation", null);
DynamicMock configurationMock = new DynamicMock(typeof(IDashboardConfiguration));
configurationMock.SetupResult("PluginConfiguration", pluginsMock.MockInstance);
viewTransformer = new LazilyInitialisingVelocityTransformer((IPhysicalApplicationPathProvider)pathMapperMock.MockInstance,
(IDashboardConfiguration)configurationMock.MockInstance);
Assert.AreEqual("foo is bar", viewTransformer.Transform("testTransform.vm", contextContents));
}
示例13: FixtureSetup
public override void FixtureSetup()
{
base.FixtureSetup();
string intType = "System.Int32";
string intRef = intType + "&";
string boolType = typeof(bool).FullName;
string boolRef = boolType + "&";
m_TextSelInfoArgs_anchor = new object[] { true, null, null, null, null, null, null };
m_TextSelInfoArgs_end = new object[] { false, null, null, null, null, null, null };
m_TextSelInfoTypes =
new string[] { boolType, "SIL.FieldWorks.Common.COMInterfaces.ITsString&", intRef,
boolRef, intRef, intRef, intRef};
m_selHelper = new DynamicMock(typeof(SelectionHelper));
m_selHelper.Strict = true;
m_selHelper.SetupResult("RestoreSelectionAndScrollPos", true);
SelectionHelper.s_mockedSelectionHelper = (SelectionHelper)m_selHelper.MockInstance;
}
示例14: CreatesAClientWithGivenClientNameIfSpecified
public void CreatesAClientWithGivenClientNameIfSpecified()
{
// Setup
DynamicMock p4Mock = new DynamicMock(typeof(P4));
P4 p4 = (P4) p4Mock.MockInstance;
p4.Client = "myClient";
p4Mock.SetupResult("ViewForSpecifications", new string[] { "//mydepot/...", "//myotherdepot/..." });
ProcessInfo processInfo = new ProcessInfo("createclient");
ProcessInfo processInfoWithStdInContent = new ProcessInfo("createclient");
processInfoWithStdInContent.StandardInputContent = "Client: myClient\n\nRoot: c:\\my\\working\\dir\n\nView:\n //mydepot/... //myClient/mydepot/...\n //myotherdepot/... //myClient/myotherdepot/...\n";
processInfoCreatorMock.ExpectAndReturn("CreateProcessInfo", processInfo, p4, "client -i");
processExecutorMock.ExpectAndReturn("Execute", new ProcessResult("", "", 0, false), processInfoWithStdInContent);
// Execute
p4Initializer.Initialize(p4, "myProject", @"c:\my\working\dir");
// Verify
p4Mock.Verify();
VerifyAll();
}
示例15: SetUp
public void SetUp()
{
CheckDisposed();
m_inMemoryCache = InMemoryFdoCache.CreateInMemoryFdoCache();
m_mainWnd = new DynamicMock(typeof(IFwMainWnd));
m_mainWnd.SetupResult("Cache", Cache);
m_app = new DummyFwApp();
}