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


C# Moq.Mock.SetupGet方法代码示例

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


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

示例1: BuildReturnsCallableDelegate

        public void BuildReturnsCallableDelegate()
        {
            var builder = new ApplicationBuilder(null);
            var app = builder.Build();

            var mockHttpContext = new Moq.Mock<HttpContext>();
            var mockHttpResponse = new Moq.Mock<HttpResponse>();
            mockHttpContext.SetupGet(x => x.Response).Returns(mockHttpResponse.Object);
            mockHttpResponse.SetupProperty(x => x.StatusCode);

            app.Invoke(mockHttpContext.Object);
            Assert.Equal(mockHttpContext.Object.Response.StatusCode, 404);
        }
开发者ID:EgoDust,项目名称:HttpAbstractions,代码行数:13,代码来源:ApplicationBuilderTests.cs

示例2: Setup

		public void Setup()
		{
			var library = new Moq.Mock<CollectionSettings>();
			library.SetupGet(x => x.IsSourceCollection).Returns(false);
			library.SetupGet(x => x.Language2Iso639Code).Returns("en");
			library.SetupGet(x => x.Language1Iso639Code).Returns("xyz");
			library.SetupGet(x => x.XMatterPackName).Returns("Factory");

			ErrorReport.IsOkToInteractWithUser = false;
			_fileLocator = new FileLocator(new string[]
											{
												//FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections"),
												BloomFileLocator.GetFactoryBookTemplateDirectory("Basic Book"),
												BloomFileLocator.GetFactoryBookTemplateDirectory("Wall Calendar"),
												FileLocator.GetDirectoryDistributedWithApplication( BloomFileLocator.BrowserRoot),
												BloomFileLocator.GetBrowserDirectory("bookLayout"),
												BloomFileLocator.GetBrowserDirectory("bookEdit","css"),
												BloomFileLocator.GetInstalledXMatterDirectory()
											});

			var projectFolder = new TemporaryFolder("BookStarterTests_ProjectCollection");
			var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection"));

			_starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), collectionSettings), library.Object);
			_shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection");
			_libraryFolder = new TemporaryFolder("BookStarterTests_LibraryCollection");
		}
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:27,代码来源:ConfiguratorTest.cs

示例3: TestHeadsetDisconnected

        public void TestHeadsetDisconnected()
        {
            var statusMock = new Moq.Mock<ICicStatusService>();
            var deviceManagerMock = new Moq.Mock<IDeviceManager>();
            var settingsManagerMock = new Moq.Mock<ISettingsManager>();

            settingsManagerMock.SetupGet(s => s.HeadsetDisconnectStatusKey).Returns(STATUS_KEY);
            settingsManagerMock.SetupGet(s => s.HeadsetDisconnectChangeStatus).Returns(true);

            var target = new StatusChanger(null, statusMock.Object, deviceManagerMock.Object, settingsManagerMock.Object);

            deviceManagerMock.Raise(d => d.HeadsetDisconnected += null, new Plantronics.UC.SpokesWrapper.ConnectedStateArgs(true, true));

            statusMock.Verify(cic => cic.SetStatus(STATUS_KEY));
        }
开发者ID:gildas,项目名称:Plantronics,代码行数:15,代码来源:StatusChangerTests.cs

示例4: IsConnectedTest

        public void IsConnectedTest()
        {
            var statusMock = new Moq.Mock<IDeviceManager>();
            statusMock.SetupGet(s => s.IsDeviceConnected).Returns(false);

            StatusViewModel target = new StatusViewModel(statusMock.Object);

            Assert.AreEqual(Visibility.Hidden, target.ConnectionVisibility);

            Assert.AreEqual(Visibility.Visible, target.ErrorVisibility);
        }
开发者ID:gildas,项目名称:Plantronics,代码行数:11,代码来源:StatusViewModelTests.cs

示例5: BuildReturnsCallableDelegate

        public void BuildReturnsCallableDelegate()
        {
            var builder = new Builder();
            var app = builder.Build();

            var mockHttpContext = new Moq.Mock<HttpContextBase>();
            var mockHttpResponse = new Moq.Mock<HttpResponseBase>();
            mockHttpContext.SetupGet(x => x.Response).Returns(mockHttpResponse.Object);
            mockHttpResponse.SetupProperty(x => x.StatusCode);

            app.Invoke(mockHttpContext.Object);
            mockHttpContext.Object.Response.StatusCode.ShouldBe(404);
        }
开发者ID:niemyjski,项目名称:HttpAbstractions,代码行数:13,代码来源:BuilderTests.cs

示例6: ProductNameTest

        public void ProductNameTest()
        {
            var statusMock = new Moq.Mock<IDeviceManager>();
            statusMock.SetupGet(s => s.ProductName).Returns(TestValue);

            StatusViewModel target = new StatusViewModel(statusMock.Object);

            string actual = null;

            target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                actual = e.PropertyName;
            };

            Assert.AreEqual(TestValue, target.ProductName);
            target.ProductName = TestValue2;

            Assert.AreEqual(TestValue2, target.ProductName);
            Assert.AreEqual("ProductName", actual);
        }
开发者ID:gildas,项目名称:Plantronics,代码行数:20,代码来源:StatusViewModelTests.cs

示例7: CreateThrottledResponse

            private static WebException CreateThrottledResponse(int throttledStatusCode, string retryAfter)
            {
                var mockWebResponse = new Moq.Mock<HttpWebResponse>();

                var responseHeaders = new WebHeaderCollection();
                responseHeaders.Add(HttpResponseHeader.RetryAfter, retryAfter);

                mockWebResponse.SetupGet<HttpStatusCode>((webRes) => webRes.StatusCode).Returns((HttpStatusCode)throttledStatusCode);
                mockWebResponse.SetupGet<WebHeaderCollection>((webRes) => webRes.Headers).Returns((WebHeaderCollection)responseHeaders);

                return new WebException("Transmitter Error", null, WebExceptionStatus.UnknownError, mockWebResponse.Object);
            }
开发者ID:iusafaro,项目名称:ApplicationInsights-dotnet,代码行数:12,代码来源:ThrottlingTransmissionPolicyTest.cs

示例8: Setup

        public void Setup()
        {
            var library = new Moq.Mock<CollectionSettings>();
            library.SetupGet(x => x.IsSourceCollection).Returns(false);
            library.SetupGet(x => x.Language2Iso639Code).Returns("en");
            library.SetupGet(x => x.Language1Iso639Code).Returns("xyz");
            library.SetupGet(x => x.XMatterPackName).Returns("Factory");

            ErrorReport.IsOkToInteractWithUser = false;
            _fileLocator = new FileLocator(new string[]
                                            {
                                                FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections"),
                                                FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections", "Templates"),
                                                FileLocator.GetDirectoryDistributedWithApplication( "factoryCollections", "Templates", "Basic Book"),
                                                FileLocator.GetDirectoryDistributedWithApplication( "BloomBrowserUI"),
                                                FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserui/bookLayout"),
                                                FileLocator.GetDirectoryDistributedWithApplication( "xMatter")
                                            });
            _starter = new BookStarter(_fileLocator, dir => new BookStorage(dir, _fileLocator, new BookRenamedEvent(), new CollectionSettings()), library.Object);
            _shellCollectionFolder = new TemporaryFolder("BookStarterTests_ShellCollection");
            _libraryFolder = new TemporaryFolder("BookStarterTests_LibraryCollection");

            Browser.SetUpXulRunner();
        }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:24,代码来源:ConfiguratorTest.cs

示例9: GetStoreBooks_ThereAre2_Returns2CollectionItems

 /* can't tell if this storeCollectionList ever existed		[Test]
         public void GetStoreBooks_ThereAre2_Returns2CollectionItems()
         {
             var b = CreateBloomServer();
             var transaction = new PretendRequestInfo("http://localhost:8089/bloom/storeCollectionList");
             b.MakeReply(transaction);
             AssertThatXmlIn.String(transaction.ReplyContentsAsXml).HasSpecifiedNumberOfMatchesForXpath("//li//h2[text()='alpha']", 1);
             AssertThatXmlIn.String(transaction.ReplyContentsAsXml).HasSpecifiedNumberOfMatchesForXpath("//li//h2[text()='beta']", 1);
             AssertThatXmlIn.String(transaction.ReplyContentsAsXml).HasSpecifiedNumberOfMatchesForXpath("//li/ul", 2);
         }
  */
 private void AddBook(string id, string title)
 {
     var b = new Moq.Mock<Bloom.Book.BookInfo>();
     b.SetupGet(x => x.Id).Returns(id);
     b.SetupGet(x => x.QuickTitleUserDisplay).Returns(title);
     b.SetupGet(x => x.FolderPath).Returns(Path.GetTempPath);//TODO. this works at the moment, cause we just need some folder which exists
     _bookInfoList.Add(b.Object);
 }
开发者ID:JohnThomson,项目名称:testBloom,代码行数:19,代码来源:BloomServerTests.cs

示例10: CreateException

            private static WebException CreateException(int statusCode)
            {
                var mockWebResponse = new Moq.Mock<HttpWebResponse>();

                mockWebResponse.SetupGet<HttpStatusCode>((webRes) => webRes.StatusCode).Returns((HttpStatusCode)statusCode);

                return new WebException("Transmitter Error", null, WebExceptionStatus.UnknownError, mockWebResponse.Object);
            }
开发者ID:jwChung,项目名称:ApplicationInsights-dotnet,代码行数:8,代码来源:ErrorHandlingTransmissionPolicyTest.cs

示例11: VersionNumberTest

        public void VersionNumberTest()
        {
            var statusMock = new Moq.Mock<IDeviceManager>();
            statusMock.SetupGet(s => s.VersionNumber).Returns(0);

            StatusViewModel target = new StatusViewModel(statusMock.Object);

            string actual = null;

            target.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                actual = e.PropertyName;
            };

            Assert.AreEqual(0, target.VersionNumber);
            target.VersionNumber = 1;

            Assert.AreEqual(1, target.VersionNumber);
            Assert.AreEqual("VersionNumber", actual);
        }
开发者ID:gildas,项目名称:Plantronics,代码行数:20,代码来源:StatusViewModelTests.cs


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