Unit-test WCF contracts match for sync / async?

Viewed 574

WCF makes it easy to call services synchronously or asynchronously, regardless of how the service is implemented. To accommodate clients using ChannelFactory, services can even define separate sync/async contract interfaces. For example:

public interface IFooService
{
    int Bar();
}

[ServiceContract(Name = "IFooService")]
public interface IAsyncFooService
{
    Task<int> BarAsync();
}

This allows the client to reference either contract version, and WCF translates the actual API calls automatically.

One drawback to providing both contract versions is that they must be kept in-sync. If you forget to update one, the client may receive a contract mismatch exception at runtime.

Is there an easy way to unit test the interfaces to ensure they match from a WCF metadata perspective?

2 Answers
Related