How can I unit test the effect of each WCF timeout setting? I want to ensure that I select good values and I also want to make sure that my exception handling code is solid.
I created client program and a server WCF service to test the timeout settings. In my service implementation, I added a Thread.Sleep(5000). On the client-side, the only setting that causes a timeout to happen is sendTimeout.
No matter which value I use in all the other settings, the timeout never occurs. How to I test all the other settings?
Here are the settings I would like to test: sendTimeout, receiveTimeout, closeTimeout, openTimeout and inactivityTimeout (in reliableSessions).
Edit 19 feb 2009 : This edit is just to indicate that I still haven't found a way to unit test the WCF timeout settings.
Not a complete answer, but the explanation of the timeout values linked below may be helpful.
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/
If you look in the right place, you can get the channel events and modify your test to be aware of them. Connect is a boolean method on the WCF service. I used svcutil to generate a proxy class using async methods.
private StateManagerClient _stateManagerClient;
private InstanceContext _site;
public New()
{
_site = new InstanceContext(this);
_serviceClient = new ServiceClient();
_serviceClient.ConnectCompleted += ServiceClient_ConnectCompleted;
}
private void ServiceClient_ConnectCompleted(object sender, ConnectCompletedEventArgs e)
{
//Bind to the channel events
foreach (IChannel a in _site.OutgoingChannels) {
a.Opened += Channel_Opened;
a.Faulted += Channel_Faulted;
a.Closing += Channel_Closing;
a.Closed += Channel_Closed;
}
}
private void Channel_Opened(object sender, EventArgs e)
{
}
private void Channel_Faulted(object sender, EventArgs e)
{
}
private void Channel_Closing(object sender, EventArgs e)
{
}
private void Channel_Closed(object sender, EventArgs e)
{
}
I hope this provides you some value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With