當前位置: 首頁>>代碼示例>>C#>>正文


C# Moq.Mock.SetupAllProperties方法代碼示例

本文整理匯總了C#中Moq.Moq.Mock.SetupAllProperties方法的典型用法代碼示例。如果您正苦於以下問題:C# Moq.Mock.SetupAllProperties方法的具體用法?C# Moq.Mock.SetupAllProperties怎麽用?C# Moq.Mock.SetupAllProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Moq.Moq.Mock的用法示例。


在下文中一共展示了Moq.Mock.SetupAllProperties方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetMocSummary

 private static Mock<ISummary> GetMocSummary()
 {
     var mocSummary = new Moq.Mock<ISummary>();
     mocSummary.SetupAllProperties();
     mocSummary.Object.TotalNumberOfPassengers = 12;
     mocSummary.Object.AdjustedTicketRevenue = 123;
     mocSummary.Object.CanFlightProceed = true;
     mocSummary.Object.InvalidInput = false;
     mocSummary.Object.LoyaltyPointsRedeemed = 12;
     mocSummary.Object.NumberOfAirlinePassengers = 3;
     mocSummary.Object.NumberOfBags = 12;
     mocSummary.Object.NumberOfGeneralPassengers = 8;
     mocSummary.Object.NumberOfLoyaltyPassengers = 1;
     mocSummary.Object.TotalCostOfFlight = 445;
     mocSummary.Object.UnadjustedTicketRevenue = 322;
     return mocSummary;
 }
開發者ID:nthandu,項目名稱:FlightSummary,代碼行數:17,代碼來源:FormatterTests.cs

示例2: Suggestionns_GetSuggestion_CheckRelevanceBoundariesAndCorrectness

        public void Suggestionns_GetSuggestion_CheckRelevanceBoundariesAndCorrectness()
        {
            // setup
            var resultMock1 = new Moq.Mock<ISuggestionInstance>();
            resultMock1.Setup(r => r.GetTextValue()).Returns("one");
            resultMock1.SetupAllProperties();
            resultMock1.Object.Rank = 1;
            var resultMock2 = new Moq.Mock<ISuggestionInstance>();
            resultMock2.Setup(r => r.GetTextValue()).Returns("two");
            resultMock2.SetupAllProperties();
            resultMock2.Object.Rank = 2;
            var resultMock3 = new Moq.Mock<ISuggestionInstance>();
            resultMock3.Setup(r => r.GetTextValue()).Returns("three");
            resultMock1.SetupAllProperties();
            resultMock1.Object.Rank = 2;
            var resultMock4 = new Moq.Mock<ISuggestionInstance>();
            resultMock4.Setup(r => r.GetTextValue()).Returns("four");
            resultMock1.SetupAllProperties();
            resultMock1.Object.Rank = 3;
            var resultMock5 = new Moq.Mock<ISuggestionInstance>();
            resultMock5.Setup(r => r.GetTextValue()).Returns("five");
            resultMock1.SetupAllProperties();
            resultMock1.Object.Rank = 4;
            var resultMock6 = new Moq.Mock<ISuggestionInstance>();
            resultMock6.Setup(r => r.GetTextValue()).Returns("six");
            resultMock1.SetupAllProperties();
            resultMock1.Object.Rank = 5;

            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock1.Object);
            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock2.Object);
            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock3.Object);

            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock4.Object);
            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock5.Object);
            this.kernel.Bind<ISuggestionInstance>().ToMethod(s => resultMock6.Object);

            // Setup two sources
            var guid1 = Guid.NewGuid();
            var sourceMock1 = new Moq.Mock<ISuggestionSource>();
            sourceMock1.Setup(m => m.GetSuggestions(It.IsAny<ISemanticObject>())).Returns(new ISuggestionInstance[] { resultMock3.Object, resultMock2.Object, resultMock4.Object, resultMock5.Object });
            sourceMock1.Setup(m => m.Guid).Returns(guid1);

            var guid2 = Guid.NewGuid();
            var sourceMock2 = new Moq.Mock<ISuggestionSource>();
            sourceMock2.Setup(m => m.GetSuggestions(It.IsAny<ISemanticObject>())).Returns(new ISuggestionInstance[] { resultMock1.Object, resultMock2.Object, resultMock6.Object });
            sourceMock2.Setup(m => m.Guid).Returns(guid2);

            this.kernel.Bind<ISuggestionSource>().ToMethod(s => sourceMock1.Object);
            this.kernel.Bind<ISuggestionSource>().ToMethod(s => sourceMock2.Object);

            // test
            var sut = this.kernel.Get<Suggester>();
            var mockKeyword = this.kernel.GetMock<ISemanticObject>();
            var result = sut.GetSuggestions(new ISemanticObject[] { mockKeyword.Object });

            Assert.That(result, Is.All.Matches((ISuggestionInstance s) => s.Rank >= 0), "Rank for one or more elements out of range.");
            Assert.That(result, Is.All.Matches((ISuggestionInstance s) => (s.Relevance <= 100 || s.Relevance >= 0)), "Relevance for one or more elements out of range.");
        }
開發者ID:serrnovik,項目名稱:SemanticDescription,代碼行數:58,代碼來源:SuggesterTests.cs


注:本文中的Moq.Moq.Mock.SetupAllProperties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。