1

有什么东西我可以用通配符(任何大于 0 的数字)替换“1”,这样传入的任何东西总是返回相同的东西等?

[TestMethod]
public void GameManagersEventsIndexReturnedWhenUserHasNoLocations()
{
    // Arrange
    List<CustomerLocation> locations = new List<CustomerLocation>();
    locations.Add(new CustomerLocation() { Active = true, Name = "Ted" });

    customerLocationDataProvider.Setup(x => x.GetAllForUserId(1)).Returns(locations);
    customerLocationDataProvider.Setup(x => x.GetAllForUserId(1).Count).Returns(0);
4

1 回答 1

3

如果您使用的是最小起订量,您可以这样做

x => x.GetAllForUserId(It.Is<int>(i => i > 0)) // condition that int value is > 0 or you can have any other conditions

或者

x => x.GetAllForUserId(It.IsAny<int>()) //if you don't care about the value
于 2013-07-20T02:15:39.693 回答