How do I mock an abstract base class constructor

2 posts, 0 answers
  1. Mike
    Mike avatar
    2 posts
    Member since:
    Oct 2018

    Posted 25 Apr 2019 Link to this post

    I am trying to test a derived class constructor, but keep hitting code in the base class constructor  This post(https://www.telerik.com/forums/mock-base-class-constructor#PUXW928ic0SPaEl3wK8Mxg) shows how to mock a base class constructor, but it does not work if the base class is abstract.
  2. Mike
    Mike avatar
    2 posts
    Member since:
    Oct 2018

    Posted 26 Apr 2019 in reply to Mike Link to this post

    I found that this was happening because I did not future mock the derived class constructo. e.g. :

    Mock.Arrange(() => new DerivedClass(<constructor arguments>)).CallOriginal().MustBeCalled();

Back to Top