Patrick\’s Bytes

1, July 2008

WCF Unit Test timeout issue

Filed under: WCF — patrickyong @ 12:16 am

image

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();

            }

         }

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: