I have an application that references a Microsoft DLL (Exchange Web Services). In my unit testing, I want to replace the Microsoft DLL with a Mock.
What works with other DLLs, doesnt work with this DLL, as i get an exception
The located assembly's manifest definition does not match the assembly reference
I verified it has the same assembly version, but i saw that the Microsoft DLL is signed digitally, so it has a PublicKeyToken. Could this be what my Application is looking for? A similarly signed DLL?
Is there a way of referencing a DLL without requiring its publickeytoken?
Thanks
You can't mock a signed DLL. (If you could you will be hired by mafia...)
Mock the code that accesses code in this dll.
Create a facade (if you don't have it), that wraps access to methods in Exchange dll. Then in your tests you can provide a mock facade.
It is a good design practice to shield your code from any third-party code (assemblies, web services, control) by the means of facades / wrappers. This minimizes the risk of impact should the third party code change, ie. upgrading to a newer version of dll (the required changes will affect only the facade) and help with testing.
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