Unit testing WCF Data Service (OData) Client library with fakes using shims - wcf

I have a class library which consumes a WCF data service (OData), is it possible to create unit tests for the library api by isolating the WCF Data service using shims(not stubs), i was searching for a sample but couldn't find any, any pointers ?

Related

Exposing WCF data type to external modules

Im doing a client server application. The server part is implemented with a WCF service. The WCF service exposes data types via service contract. The client is modularized and uses MEF for DI. In the client I have a infrastructure module that references the WCF service. The infrastructure module knows about the WCF data types. My question is , is it possible to let the other modules that references the infrastructure to know about these data types without adding a reference to the WCF service in every module. Is there any way of of exposing the WCF data types
Normally, you have a contract dll. This contract dll contains the service interface and all dependent classes. Your WCF service and any client component will then reference this contract assembly.
As the contract assembly only contains interfaces and POCOs (Plain Old CLR Object, only data, not methods or logic), it can be referenced from virtually anywhere without giving away anything about your infrastructure.
nvoights answere is probably the correct one here however it is also worth mentioning that if you control both server and client then you can if you want put common objects in a dll consumed by both and ignor the WCF generate types. In some senarios that works out better than managing both the server types and the WCF generated equivalent types.

Wrap the Application Service in ASMX or expose directly via WCF?

I have an application service layer (which all return serializable viewmodels). Some of these app services need to be callable via AJAX by client code in the Web UI. I'm currently wrapping them in ASMX files that do nothing but dictate the response format as JSON delegate each call to the application service class with the same signature.
Is it advisable to try to save a few lines of code by exposing the appropriate application service classes as WCF services? Can someone point me to an example? Any potential pitfalls for usage in WebForms client code?
Microsoft now considers ASMX services to be "legacy technology". You should not use them for any new development. They have been completely replaced by WCF. For instance, see the top of this article: http://msdn.microsoft.com/en-us/library/bb885203.aspx:
This topic is specific to a legacy
technology. XML Web services and XML
Web service clients should now be
created using Windows Communication
Foundation .

How to mock web service call in a WF workflow?

I'm implementing a WCF web service based on WF. This web service consumes other web services which I'm not in charge of. So basically my service workflow contains several Send activities.
I'm following the TDD approach, so the service implementation is to be covered by unit tests. I want to test proper invocation of 3rd party services.
In a non-workflow case I would mock the external services via NMock. But in my case I cannot control the instantiation the workflow instance and I have no idea on how to trick the Send activities to use the mock objects instead of real services endpoints.
Although Unit Testing Workflows And Activities article on MSDN mentions mocks I couldn't find any complete example of mocking the remote end of Send activity.
Any idea on how to do that?
please try Moles framework. http://research.microsoft.com/en-us/projects/pex/
There are samples about how to mock the sharepoint service. I believe the same trick should apply to WF workflow.
I have tried to mock the sqlconnection, Entity framework, web service call, it works very neat. Basically, it can mock almost any .net objects.
Using ServiceAgents wrappers for your web services would be one possible way of doing it.
This is a pattern i have followed in previous projects of mine.
Since they are interface based, you can easily mock out the services.
There are other advantages to this pattern (besides unit testing) including being able to abstract your application from external dependencies to a certain extent. However it does add the overhead of creating another class layer on top of the services.

WCF MSMQ Unit testing

I have created a custom msmq service with WCF, which uses a custom binding as it needs to do some custom logic at the channel layer, where it calls another wcf service. The service is going to be a core pience of functionality for our systems for at the the next few years. i want to do what I can to make sure the service is robust, but, i'm not sure where to start. Ie testing the response, should I create a mock queue object? how do I test the service is calling another service ?
Best way I have found to unit test msmq services is to actually unit test the service implementation, then do an integration test using msmq with a mock repository. To see if writes are working.

How two diffrent projects running on java and .net can interact with each other using WCF?

I have a wcf services projects and a second project for consuming these services is in java.
My question is how can i create proxy classes for java to consume my wcf services ?
Is there any other way to consume wcf services through Java clients ?
WCF is like a wrapper for all kind of communication you might want to do.
So if you want, you can make your wcf services use SOAP as a communication method, which the java side should be able to implement.
More info about wcf