单元测试文化错误

时间:2013-12-14 14:20:39

标签: c# .net visual-studio-2012

我想对我构建的这个库执行单元测试但是当我尝试构建解决方案时,它失败了。我没有以任何方式触及文化,我试图查看Microsoft.Common.targets中的代码,但我根本无法弄清楚问题可能是什么。

确切的错误如下:

1>------ Build started: Project: CardTests, Configuration: Debug Any CPU ------
1>Build started 14-12-2013 15:14:41.
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): error MSB3095: Invalid argument. Culture is not supported.
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): error MSB3095: Parameter name: name
1>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): error MSB3095: en-UK is an invalid culture identifier.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.02
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

修改

这是我执行的测试:

using System;
using System.Threading;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Game;

namespace CardTests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Deck d = new Deck();

            Console.WriteLine(d.GetCard().ToString());

            d.Shuffle();

            int i = 1;
            foreach (Card c in d.GetCards(10))
            {
                Console.WriteLine(i + ".: " + c.ToString());
                i++;
            }
        }
    }
}

2 个答案:

答案 0 :(得分:1)

我发现这是图书馆的AssemblyCulture(我从未改变过),这就是问题所在。

答案 1 :(得分:0)

这可能有多种原因......

  • 资源格式无效的Resource.{culture}.resx名称的资源文件
  • AssemblyInfo.cs中的NeutralResourcesLanguages属性不正确
  • 代码中的AssemblyCulture属性,此属性应由编译器添加,而不是在您自己的代码中添加。
  • 引用satilite程序集(assembly.{culture}.dll)而不是基本程序集。
相关问题