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
0 votes
Get an exception when creating a mock object of a class (abstract). Note that it still does it if the constructor is changed from proteced to public.

Caused by following line:
TypeMock.MockObject mockDSPObjectModel1 =
TypeMock.MockManager.MockObject(typeof(DSPObjectModel));

Class outlines for DSPObjectModel and base class:

public abstract class DSPObjectModel :
ExtendedTypeDescriptor, IDSPObjectModel, IKnowMySystemName {

protected DSPObjectModel(IDSPObject dspObject) {
...
}

[Serializable]
public class ExtendedTypeDescriptor : ICustomTypeDescriptor {

public ExtendedTypeDescriptor(object helped) {
this.helped = helped;
}

public ExtendedTypeDescriptor() {
this.helped = this;
}
...
}

Exception:
Type:
System.NotSupportedException
Message:
Parent does not have a default constructor. The default constructor must be explicitly defined.
Thread:
Name '', Id = 860
StackTrace:
at System.Reflection.Emit.TypeBuilder.DefineDefaultConstructor(MethodAttributes attributes)
at System.Reflection.Emit.TypeBuilder.CreateType()
at TypeMock.s.b(Type A_0)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TypeMock.MockManager.MockObject(Type type, Object[] args)
at Servotest.D2R.Model.Test.TestItBody() in c:d2rGenericsrcModelModelSynchronizer.cs:line 452
at Servotest.UnitTest.MessagingThreadTestbed.ExceptionCatcherMethod(VoidZeroArgDelegate testDelegate) in c:d2rTestingsrcUnitTestMessagingThreadTestbed.cs:line 66
asked by servotest bob (3.8k points)

2 Answers

0 votes
Get an exception when creating a mock object of a class (abstract). Note that it still does it if the constructor is changed from proteced to public.

Hi,
:arrow: This is solved in the Beta Release and the Next release that will be out pretty soon , I know that you have a problem with the current beta release, we are solving it, and a workaround is proposed in the Beta Forum.
answered by scott (32k points)
0 votes
Fixed in version 3.0.0 8)
answered by scott (32k points)
...