2013-12-14 93 views
1

我想對我建立的這個庫執行單元測試,但是當我嘗試構建解決方案時,它失敗。我沒有以任何方式觸及文化,我試圖看看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++; 
      } 
     } 
    } 
} 
+0

你可以發佈測試嗎? –

+0

當你雙擊編譯錯誤時,VS會帶你去哪裏? – rhughes

+0

@rhughes,錯誤不包含任何行號的文件名,除了'Microsoft.Common.targets',所以沒有直接鏈接到導致此錯誤的源文件。 – jessehouwing

回答

1

我發現它是圖書館的AssemblyCulture(我從未改變過),那就是問題所在。

+0

那麼,你是如何解決它的? – whybird

0

這可能有很多原因,......

  • 一個種源文件與Resource.{culture}.resx名稱與格式無效
  • 在AssemblyInfo.cs中一個NeutralResourcesLanguages屬性這是不正確
  • AssemblyCulture屬性在你的代碼,這個屬性應該由編譯器添加,而不是在自己的代碼。
  • 參照satilite組件(assembly.{culture}.dll)而不是基座組件。