This is a migrated thread and some comments may be shown as answers.

Arrange variables inside Private method

2 Answers 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sagar
Top achievements
Rank 1
Sagar asked on 05 Mar 2015, 07:12 AM
Hi,
  I am facing trouble, while Arranging value of a variable inside a Private Method. Below is a sample code snippet for the scenario that i am working on, which has a Private static method. In method "SomeMethod", i want to arrange the call "someObject.MethodReturnsTrueOrFalse(someValue)".
  Can anybody give me resolution on the same?

public class SomeClass
{
   
 private static void SomeMethod()
 {
int someValue = 10;
Foo someObject = new Foo();
        var result = someObject.MethodReturnsTrueOrFalse(someValue);
        if(result)
{
//do some operation
}
 }
}
Thanks In advance :)

Sagar





2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 05 Mar 2015, 12:48 PM
Hello Sagar,

Future mocking will come handy in this situation:
Mock.Arrange(() => Arg.IsAny<Foo>().MethodReturnsTrueOrFalse(Arg.AnyInt)).Returns(true);

If MethodReturnsTrueOrFalse is itself private, then you'll need to go through the non-public mocking API.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sagar
Top achievements
Rank 1
answered on 05 Mar 2015, 02:06 PM
Thanks Stefan, that solves my query.

Thank you,
Sagar
Tags
General Discussions
Asked by
Sagar
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Sagar
Top achievements
Rank 1
Share this question
or