编辑:此问题已在Github上提交。将“Act”部分更改为此将使测试通过
var result = Adresse.All()
.Where(x => x.AdresseX == txt1 && x.PostBy == txt2)
.FirstOrDefault();
[TestMethod]
public void WTF()
{
//Arrange
string txt1 = "Vingsted Skovvej 1";
string txt2 = "7100 Vejle";
var one = new Adresse { ID = 1, AdresseX = "Vejlevej 55", PostBy = "7300" };
var two = new Adresse {ID = 2, AdresseX = txt1, PostBy = txt2 };
Adresse.Setup(new List<Adresse> { one, two });
//Act
var result = Adresse.SingleOrDefault(x => x.AdresseX == txt1 && x.PostBy == txt2);
//Assert
Assert.AreEqual(2, result.ID);
}
以下测试让我失望,因为我得到第一个对象(ID等于1的那个)...有人可以向我解释我做错了什么???