开发者

How create an instance of an abstract class with internal members using remoting / proxy?

开发者 https://www.devze.com 2023-01-12 09:56 出处:网络
I was playing around with Microsoft Entity framework 4 and at some point i want to create a fake instance of ObjectStateEntry using a proxy or FormatterServices and faced with the issues that follow:

I was playing around with Microsoft Entity framework 4 and at some point i want to create a fake instance of ObjectStateEntry using a proxy or FormatterServices and faced with the issues that follow:

  1. The class has internal abstract members therefore creating a proxy ends up with type having not-implemented members. Therefore, throws exception during CreateInstance.
  2. Can't use FormatterServices.GetUinitializedDat开发者_运维百科a as it is an abstract class.

Would love to know, if are there any other option available ?


Here I wrote down my answer as soon as I saw your question title How create an instance of an abstract class, the answer is No, you can't create an instance of an abstract class.


Have you tried any mocking framework such as Rhino Mocks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号