First, I love Code Contracts but I'm a little confused with one thought:
My class MyClass
uses a dependency being an interface IDependency
for which contract class (internal abstract class IDependencyContracts
) is declared and my class heavily relies on these contracts. I have no guarantees contracts were enforced for custom implementation of the interface provided by the client code.
As far as I understand I can enforce contracts only on classes in my assembly, but I have no control on client code assemblies.
Then must I use Contract.Assert()
in code where interface is used to check whether returned result meets expectations?