Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a tool I can use to generate interfaces and wrappers for object mocking in c#
    text
    copied!<p>Given a class like System.Timers.Timer, or ANY managed class (whether user defined, from the .net framework, or some 3rd party library) is there some program I can use to (a) generate an interface based on this class and (b) generate a wrapper for the given class?</p> <p>for example if I have a </p> <pre><code>public class Foo { public object MyProperty { get { ... } set { ... } } public int SomeMethod(object a) { ... } } </code></pre> <p>it will create an interface</p> <pre><code>interface IFoo { object MyProperty { get; set; } int SomeMethod(object a) { ... } } </code></pre> <p>and maybe even a wrapper</p> <pre><code>class FooWrap { // something for relay constructor here ... Foo _me; public object MyProperty { get { return _me.MyProperty; } set { _me.MyProperty = value; } } public int SomeMethod(object a) { return _me.SomeMethod(); } } </code></pre> <p>Obviously there's stuff I haven't thought about like events, generics etc. I want a DWIMNWIS-PSICHTO(-Plus-Stuff-I-Clearly-Haven't-Thought-Of).</p> <p>I'm aware resharper/vs can be used to extract an interface but I've only been able to use this on my own classes. </p> <p><sub>Aside: Wow, it is amazing how simply becoming accustomed to a previously 'unacceptable' idea eventually gives it legitimacy. A year ago the idea of having to create interfaces for all objects I want to mock and adopting an injection framework would have seemed like the height of madness. It turns out that while it's not quite death and taxes, it is sparta.</sub></p> <p><sub>I am aware of and have used typemock. It certainly is the work of elvish wizards. One day when $800 does not seem like quite so much money I intend to buy it.</sub></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload