0
我需要爲WCF Rest服務編寫一個單元測試。 這是方法之一:如何寫一個單元測試WCF Rest服務
接口:
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "CustomerProfile")]
Model.Customer CustomerProfile();
實現:
public Model.Customer CustomerProfile()
{
return GetCustomerInfo.Instance.returnCustomerProfile();
}
returnCustomerProfile方法會調用數據庫,並返回客戶信息。
在單元測試項目中,我添加了服務URL。我不知道如何繼續。如果你有任何網站或樣本會幫助很多。
[TestMethod]
public void TestUpdatePasswordWeb()
{
string strServiceUrl = "http://localhost:64440/CustomerRestService.svc/UpdatePassword";
....
}