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


C# DynamicMock.SetupResult方法代码示例

本文整理汇总了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;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:38,代码来源:NotesEditingHelperTests.cs

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

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

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

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

		}
开发者ID:kascomp,项目名称:CruiseControl.NET,代码行数:32,代码来源:ProjectReportProjectPluginTest.cs

示例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;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:55,代码来源:FootnoteEditingHelperTests.cs

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

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

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

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

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

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

示例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;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:20,代码来源:DraftViewInsertVerseNumberBtTests.cs

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

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


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