chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Suppose I have an abstract class that I need to mock to use in the test of another class:

public abstract class MyAbstractClass

In the particular case of this test, I need the class to be serializable. It would be nice to have something like this:

RecordManager.CreateMockObject<MyAbstractClass>(Constructor.Mocked, StrictFlags.AllMethods, new Attribute[] { new SerializableAttribute() }, ...);

Since the number of parameters for CreateMockObject is starting to grow, a settings class could be introduced:

public class CreateMockObjectSettings
    Constructor Constructor { get; set; }
    StrictFlags StrictFlags { get; set; }
    object[] Parameters { get; set; }
    Attribute[] CustomAttributes { get; set; }
    // ...

With the new C# 3.0 object creation syntax, the legibility is good:

RecordManager.CreateMockObject<MyAbstractClass>(new CreateMockObjectSettings { Constructor = Constructor.Mocked, StrictFlags = StrictFlags.AllMethods, CustomAttributes = new Attribute[] { new SerializableAttribute() } });
asked by paulo.morgado (11k points)

1 Answer

0 votes
Hi Paulo,

Thanks for this suggestion as well. We'll add it to our feature wish list, and see how we fit it into a future version. As always, I encourage people to sound out if they would like a feature like that as well.
answered by gilz (14.5k points)