Are WCF Data Services (ODATA Services) Testable ? Can we write Unit Test for WCF Data Service

StackOverflow https://stackoverflow.com/questions/19400496

  •  30-06-2022
  •  | 
  •  

Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top