locked
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

     

     

    MClassA

     

    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.

    http://social.msdn.microsoft.com/Forums/en/pex/thread/0e6ed0c0-5ffc-46b7-96da-65847c463e33



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

Answers

  • 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