0

I need to verify that a class method calls base class method. Here is the code structure

public abstract class BaseClass
{
    protected virtual void MethodA()
    {    
    }
}

And class that needs to be tested

public abstract class MainClass : BaseClass
{
    public void MethodB()
    {    
        base.MethodA();
    }
}

I want to write a test that would verify that when I call MainClass.MethodB() then BaseClass.MethodA() gets called. Is this possible?

1 Answers1

-1

Add a Console.WriteLine("MethodA() was called");

EventLogs works too.

https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog?view=net-5.0

  • OP wants to verify this programmatically as part of a unit test. Please pay close attention to the tags they used on the question: `[unit-testing]` and `[moq]` (a mocking library). – ProgrammingLlama Mar 20 '21 at 13:13