I have a WCF client where I get data via OData. I want to unit test my client and already made an interface for the DataServiceContext:
internal interface ODataServiceContext
{
DataServiceResponse SaveChanges(SaveChangesOptions options);
ReadOnlyCollection<LinkDescriptor> Links { get; }
...
}
For my test currently I need to fake the Links
property. I need to return at least one LinkDescriptor. Does anybody has an idea how to achieve this?
For now I use NSubstitute for faking the interface:
var context = Substitute.For<ODataServiceContext>();
var list = new List<LinkDescriptor>();
var links = new ReadOnlyCollection<LinkDescriptor>(list);
context.Links.Returns(links);
This works for testing. But how can I achive to add a link descriptor to the collection as it has no public constructor and is sealed?
Aucun commentaire:
Enregistrer un commentaire