mole other methods in the class under testing RRS feed

  • Question

  • Hi all

    I have read this question called “How to mole other methods in the class under testing”. The detail is when we  unit testing method1, which uses method2 in the same class. Can we mole method2?


    Class A


        private void Method1 ()



             val = Method2();




       private int Method2()





    This is the answer





    classAMole = new MClassA();

    classAMole.InstanceBehavior = MoleBehaviors.Fallthrough;

    classAMole.Method2 = () => 2;


    I have try unit as this ,but it doesn't work. 

    Did anyone try as this?  I did as this but it didn't work...

    If we can moled instance as this ,every thing will be more convenience.


    • Edited by what a name Friday, October 14, 2011 7:58 AM
    Friday, October 14, 2011 7:56 AM


  • Hello, The Pex and Moles team now monitors their forums on Stack: http://stackoverflow.com/questions/tagged/pex-and-moles Thanks Chuck
    Tuesday, October 18, 2011 1:42 AM