2013-07-26 46 views
3

我有以下方法成功地工作:本地化測試是在命令行中失敗,但在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,則此特定測試會通過,但是稍後會在該資源文件中直接進行其他測試。

+0

可能的路徑問題,與此類似:http://stackoverflow.com/questions/2686815/mstest-project-cant-get-localized-string? – BartoszKP

回答

1

嘗試設置也Threading.Thread.CurrentThread.CurrentCulture

1

是從資源,以同樣的方式應用程序的命令行版本訪問,因爲它們是從Visual Studio訪問?

enter image description here

相關問題