Silverlight 4.0 Silverlight单元测试-本地化

Silverlight 4.0 Silverlight单元测试-本地化,silverlight-4.0,tdd,Silverlight 4.0,Tdd,我正在开发Silverlight应用程序,遇到了一个与单元测试相关的问题。 这个单元测试的目的是测试本地化 默认情况下,文化是英语,我想测试一下法国文化。 我尝试设置区域性、UI区域性和DeploymentItem属性。但是没有成功 这是我的测验 using Microsoft.VisualStudio.TestTools.UnitTesting; [TestClass] public class SampleTest { [TestMethod] [DeploymentItem(

我正在开发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文化,也总能获得英语价值观

有人能想出解决这个问题的办法吗

谢谢, 马赫什。

马赫什

只是为了让别人知道我们是如何解决这个问题的。我们已经发现,解决方案是在Silverlight UnitTest项目的AppMenifest.xml文件中的Deployment.Parts节点中添加AssemblyPart。(默认情况下,fr资源文件不包括在UnitTest项目xap文件中)


谢谢

Dax

Mahesh

只是为了让别人知道我们是如何解决这个问题的。我们已经发现,解决方案是在Silverlight UnitTest项目的AppMenifest.xml文件中的Deployment.Parts节点中添加AssemblyPart。(默认情况下,fr资源文件不包括在UnitTest项目xap文件中)


谢谢

达克斯

<AssemblyPart Source="fr/MyProject.resources.dll" />