I am creating some Unit Test for my IssueTracker project. My unit test class will connect to a WCF service and execute command. Whenever I start testing the code, after awhile the test just hang there until timeout and returns the follow message.
Failed TestAddIssueAttachment IssueTrackerTest Assert.Fail failed. The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I am suspecting something is not right with my code. So I start searching the web, and I came across the following post by fellow MVP Benjamin Day. He had the same issue and realized actually he forgot to close the proxy connection. Yup, WCF proxy has to be closed, refer the unit test code sample below
[TestMethod]
public void TestDeleteIssueAttachment()
{
IssueTrackerService.IssueTrackerServiceClient client
= new IssueTrackerService.IssueTrackerServiceClient();
try
{
client.Open();
list = client.ListIssueAttachments().ToList();
…..
} finally {
client.Close();
}
}