2008-10-30 35 views
0

我是一名使用Visual Studio 2008內置單元測試組件的新手,在單元測試中記錄或顯示結果的最佳方法是什麼?在VS 2008中顯示單元測試結果

我想測試我的服務方法,當它返回的System.Guid和一個空的System.Guid

[TestMethod] 
public void GetGUID() 
{ 
    MyWcfServiceService.MyWcfServiceClient proxy = new MyWcfServiceService.MyWcfServiceClient(); 
    string name = "HasGuid"; 

    System.GUID guid = proxy.GetGUID(name); 
} 

[TestMethod] 
public void GetEmptyGUID() 
{ 
    MyWcfServiceService.MyWcfServiceClient proxy = new MyWcfServiceService.MyWcfServiceClient(); 
    string name = "HasEmptyGuid"; 

    System.GUID guid = proxy.GetGUID(name); 
} 

回答

5

對於GetGUID()...

Assert.IsFalse(guid == Guid.Empty); 

類似地,對於GetEmptyGUID()...

Assert.IsTrue(guid == Guid.Empty); 
0

我用這個去年幾個月,IIRC是不是有Assert類? Assert.IsTrue(...)

我已經放棄VS測試的東西贊成其他單元測試框架(更好的國際海事組織),所以我的記憶可能蒙上陰影。

+0

呀其Assert.IsTrue(條件 「消息」)或Assert.XXX( x,「消息」)。 – cfeduke 2008-10-30 21:52:35