C# How can I force Localization Culture to en-US for tests project

后端 未结 6 1035
清酒与你
清酒与你 2021-02-02 07:33

How to specify concrente Localization Culture for tests project in C# in VS2008? I\'m building Asp .Net MVC app that has nonstandard culture specified in web.config but how to s

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 07:40

    If you're using xUnit, you can add the UseCultureAttribute to your project, as defined here:

    https://github.com/xunit/samples.xunit/blob/master/UseCulture/UseCultureAttribute.cs

    To use it:

    [Fact]
    [UseCulture("en-US")]
    public void MyTest()
    {
        // ...
    }
    

提交回复
热议问题