我的單元測試在c#中一直保持失敗,我嘗試了幾種不同的方法。任何幫助將不勝感激。這只是不轉換我添加到小寫的書。所以測試失敗單元測試未能在c中將字符串列表轉換爲小寫#
private List<string> _number;
public Book (string[] id)
{
//_number = idents.Select (d => d.ToLower()).ToList();
_number = new List<string>(id);
_number = _number.ConvertAll (d => d.ToLower());
}
public bool Exist (string id)
{
return _number.Contains (id);
}
public void AddBook (string id)
{
_number.Add (id.ToLower());
}
_______________________________________________________________________________
[Test()]
public void TestAddBook()
{
Book id = new Book (new string[] {"ABC", "DEF"});
id.AddBook ("GHI");
Assert.AreEqual (true, id.Exist ("ghi"));
}
你在AddIdentifier中將它轉換爲小寫嗎? – artm 2014-10-20 01:23:23
不知道爲什麼這是倒投了,似乎是一個合法的問題。 – 2014-10-20 01:24:09
聲明瞭「_name」變量和「AreYou」方法在哪裏? – TheVillageIdiot 2014-10-20 01:29:36