Mocking a base class method call with Moq

后端 未结 6 1796
不思量自难忘°
不思量自难忘° 2020-12-06 16:12

I am modifiying a class method which formats some input paramater dates which are subsequently used as params in a method call into the base class (which lives in another as

6条回答
  •  甜味超标
    2020-12-06 16:40

    wrap the base class method in a method and setup that method e.g.

    public class B : A
    {
        public virtual BaseMyMethod(object input)
        {
            // Do something
            base.MyMethod(input);
        }    
    public override MyMethod(object input)
        {
            // Do something
            BaseMyMethod(input);
        }
    }
    

    and now Setup the BaseMyMethod

提交回复
热议问题