I have a class A
that expose a HttpRequestHeaders
as a property. The class under test is B
.
B
is usingA
.A
is also a fake class that is used only for unit test.A
inherit an interface that impose the definition of theHttpRequestHeaders
property.
So I need to substitute the HttpRequestHeaders
so that I can test B
Unfortunately HttpRequestHeaders
is a sealed class thus it can not be substitute by NSubstitute:
Could not load type 'Castle.Proxies.HttpRequestHeadersProxy_2' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a621a9e7e5c32e69' because the parent type is sealed.
What would be the general solution to overcome this situation?