我有以下方法成功地工作:本地化測試是在命令行中失敗,但在VS
[TestMethod]
public void Message_TestToEnglishString()
{
// Set the thread to French to get the French resource
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr");
string frenchMessageBase = MessagesResources.USER_LOGGED_IN;
Assert.AreNotEqual("{0} logged in.", frenchMessageBase);
}
這個工程完全按照預期在Visual Studio。從英語資源文件"{0} logged in."
中提取值時,對命令行中相同代碼的相同測試運行失敗。
任何有關爲什麼會發生這種情況的見解,以及如何解決它?
如果我設置了資源文件Culture,即MessagesResources.Culture
,則此特定測試會通過,但是稍後會在該資源文件中直接進行其他測試。
可能的路徑問題,與此類似:http://stackoverflow.com/questions/2686815/mstest-project-cant-get-localized-string? – BartoszKP