2
votes

I am trying to Test WCF data Service (ODATA SERVICES) using UNIT TEst but I am not able to do so.

Can any one help ?

1
Welcome to SO. You really need to add more information to your question, like what have your tried, what went wrong, log data, anything that could help people answer the question. Also we are not here to hand out solutions but help locate issues. Spending a few minutes reading the about page is a really good start. :) - Qben

1 Answers

2
votes

You can unit test data services by directly calling functions on the data service class itself (internal / white box testing) or you can unit test by constructing an in-process service and calling the data service via http requests.

Calling the data service class directly will exercise the logic there, but the risk is that the data service may have assumptions / dependencies on using the network stack state as part of processing the request. If it does, then unit tests that call the data service directly will probably fail because the test environment does not correctly reflect the runtime environment.

Setting up the data service as an in-process service and accessing it through http requests in your unit tests provides a better representation of the real-world runtime environment, because the calls are actually going through the network stack and being dispatched to the data service as they would be at runtime. If the data service is truly independent of the network state, this may be overkill but it is a better representation of real world operations.