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