I am trying to use automocking to test a class that looks something like this:
class X
{ public X(int code, IFoo a, IBar b, IBaz c, ...) { ... }
}
Using automocking how do I go about getting the int into the class under test?
1 Answer, 1 is accepted
0
Kaloyan
Telerik team
answered on 15 Nov 2012, 01:24 PM
Hello Eric,
Thank you for contacting Telerik support.
In order to help you further, I must object that the Automocking container of JustMock is designed to mock non elevated external dependencies(mostly Interfaces). However, we have planned the using of profiler in it for future releases. I would recommend you to check our help documentation about this feature:
- http://www.telerik.com/help/justmock/basic-usage-automocking.html
Noting the above, I must say that, with automocking it is not possible to pass a value type along with the external dependencies(the interfaces) into the constructor. Let`s assume we have the following code to be tested:
public interface IFoo
{
int MyFooProp { get; set; }
}
public interface IBar
{
string MyBarProp { get; set; }
}
public interface IBaz
{
bool MyBazProp { get; set; }
}
public class X
{
public int SampleInt { get; set; }
public int IntegerValue { get; set; }
public string StringValue { get; set; }
public bool BoolValue { get; set; }
public X(int code, IFoo a, IBar b, IBaz c)
{
this.SampleInt = code;
this.IntegerValue = a.MyFooProp;
this.StringValue = b.MyBarProp;
this.BoolValue = c.MyBazProp;
}
}
Using the automocking feature will make the "code" variable to be passed with it`s default value which is "0" and the following test will behave as expected: