.net - Non-code-generated forwarding shim for testing private methods -


In general, I design classrooms in a manner that does not require privatization for testing purposes. One can also help.

However, I am currently working with a codebase in which there are some areas which are dependent on [VSTS] in the private accessory system (i.e., VSCodeGenAccessors Code> * _Accessor To apply classes that use forwarding, private to apply the members (and optionally internal ).

Then I have the code:

  class intends to target = new classware (); var ACCESSOR = ClassroomTest_AssessorAttachShaido (Target); ACCESSOR.PrivateMath (); (Yeah, there is cheat with the opponent - but please do not shoot the messenger). (Pure,  

I have many The problems are:

  1. I would like to be able to clarify what personal requirement I have
  2. I do not like to start the dialogue (yes, I am a I am not khoholic)
  3. I did not want code generation in the picture Insert

    That's why I want to be able to the above code to convert a few:

      var target = new classUnderTest (for); ICLsTestTeT Interface Accessor = Shadow.com & lt; ICLSUNTTT Interface & gt; (aim); Accessor.PrivateMethod (); Assurance Rate (accessor._privateMethodWasCalled); Accessor.PrivateProperty = 5; Claim it. Aquil (accessor.printproperty, 5);  

    In my test assembly, there are no generated codes or custom build steps, only with the following interface: -

      Interface ICSLTTtext interface {int PrivateProperty {Get; Set;} bool _privateMethodWas called {get; } Zero private method (); }  

    From there, I'm able to use CodeRush or Ctrl KM to generate new shadow methods only on the interface with a keystroke.

    There is a way I shadow.Creative & lt; I & gt; (Object o) which will generate a dynamic proxy which implements the interface 1. Confirm that the object o is wrapped up by all the interfaces of the members determined by 1.bnous: field of Forwarding management of the representation property (i.e., `_privateMethodWasCalled ')

    So, does anyone know of such a library that something like this (or are it feeling bored enough to write it?)

    One obvious flaw is that you do not We know that the interface is not compatible with the ClientInternet by the runtime, but it is okay because it will be for testing only. Besides, AIUI, Private Accessory System needs to re-compile the trigger to synchronize content from time to time. is.

    Or is there any way better way I remember? (Remember that I do not want to make the hip to make myself private or public to go blankets and do not rewrite the code working)

    xUnit.net, .NET 3.5; Open to use any dynamic proxy library or other

Do you see the frameworks like muke or rhino Have fun? In your case, they can help if you are ready to change the personal changes that need to check your 'safe virtual' (which is not bad internally). In fact, if the member is virtual, the joke of the structure can produce a dissection which records what the members are called.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -