Reputation: 259
I am using Moq for unit testing in C# and want to put some fake data in the following class.
public class UserResponse
{
public IEnumerable<usertab> userlist{get;set;}
public string Name {get;set;}
public string state {get;set;}
public string country {get;set}
}
public class usertab
{
public string tname {get;set;}
public string fname {get;set;}
}
Please correct me if below code is correct to fake a class wtih IEnumerable
var userdata = new usertab[]{
new usertab{tName="Employee",fName="abc"},
new usertab{tName="Employee",fName="xyz"},
};
Upvotes: 0
Views: 326
Reputation: 1503459
Well you're not "faking" it at all - you're just using an array as the implementation. There's nothing wrong with doing that - personally I like using real code within tests, so long as:
Upvotes: 3