Using Moq To Test An Abstract Class

前端 未结 2 1078
臣服心动
臣服心动 2020-12-31 07:01

I am trying to run a unit test on a method in an abstract class. I have condensed the code below:

Abstract Class:

public abstract class TestAb
{
            


        
相关标签:
2条回答
  • 2020-12-31 07:44

    The message is because your Test method is not public. Test methods need to be public. Even after making the test method public it will fail as you can only verify abstract/virtual methods. So in your case you will have to make the method virtual since you have implementation.

    0 讨论(0)
  • 2020-12-31 07:50

    If you want to mock methods on an abstract class like this, then you need to make it either virtual, or abstract.

    0 讨论(0)
提交回复
热议问题