2015-12-07 68 views
0
//Claim class Developed in solution ABC 
class Claim 
{ 
    public Claim(string s) 
    { 
     // progreamm..... 
    } 
} 

//Test Case needs to write in Solution XYZ 
[TestClass] 
public class ClaimTest 
{ 
    public void myconstructor() 
    { 
     //Now Question is how to access class Claim here? 
    } 
} 

//Now Question is how to access class Claim constructor in myconstructor //function. 

//Hope you get what i need to access using Just Mock in telerik 
+0

你不應該需要單元測試內部類;只有公共API。如果您無法通過使用它的公共類正確地測試'Claim',那麼您的代碼設計存在問題。 –

回答

2

您所做的是將InternalsVisibleTo屬性添加到包含內部類的程序集。它在JustMock documentation中有解釋。

[assembly: InternalsVisibleTo("TestAssembly")] 
[assembly: InternalsVisibleTo("Telerik.JustMock, PublicKey=0024000004800000940000000602000000240000525341310004000001000100098b1434e598c6" + 
"56b22eb59000b0bf73310cb8488a6b63db1d35457f2f939f927414921a769821f371c31a8c1d4b" + 
"73f8e934e2a0769de4d874e0a517d3d7b9c36cd0ffcea2142f60974c6eb00801de4543ef7e93f7" + 
"9687b040d967bb6bd55ca093711b013967a096d524a9cadf94e3b748ebdae7947ea6de6622eabf" + 
"6548448e")] 

之後,重建裝配,然後你可以在測試組件使用的內部類型,就好像它們是公共類型。