2013-07-20 44 views
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); 
+1

我編輯了自己的冠軍。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

+0

@John Saunders謝謝 – 1Canuck16

回答

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