我有以下方法成功地工作:本地化测试是在命令行中失败,但在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