2
我正在開發Silverlight應用程序,並遇到與單元測試相關的一個問題。 這個單元測試的目的是測試本地化。Silverlight單元測試 - 本地化
默認文化是英語,我想測試法國文化。 我嘗試設置文化和UI文化和DeploymentItem屬性。但沒有成功。
這裏是我的測試
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class SampleTest
{
[TestMethod]
[DeploymentItem(@"Bin\fr", "fr")]
public void Test Method()
{
SetSpecificCurture(false);
string test = EngineAnomaliesViewStrings.Identifier;
Note: [EngineAnomaliesViewStrings is my resource file]
Assert.AreEqual("Some French Test", test);
}
private void setSpecificCurture(Boolean isUkLable)
{
CurrentUserLogged.Details.IsUKLanguage = isUkLable;
string culture = isUkLable ? "en" : "fr";
string dateFormat = isUkLable ? "MM/dd/yyyy" : "dd/MM/yyyy";
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = dateFormat;
Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern = dateFormat;
}
即使通過設置FR文化,總是讓英語值。
任何人都可以有一個想法來解決這個問題嗎?
謝謝, Mahesh。