I have a repository interface, for example:
public interface IUserRepository { IEnumerable<User> ListUsers(); User GetUserById(int id); void AddUser(User user); void DeleteUser(User user); void EditUser(User user); } where User , for example, looks like this:
public class User { public int Id { get; set; } public string Name { get; set; } public IEnumerable<Role> { get; set; } public string Email { get; set; } } just in case,
public class Role { public int Id { get; set; } public string Name { get; set; } } What is the easiest way to make an imitation of this repository with fake data?
If you simply make a singleton inside which you define a
List<User>, then this confuses me, because there will be differences in behavior from the real repository. If in the real repository two timesGetUser(id)(with the sameid), then we get two instances of the object. And if in the singleton or static class we also get 2 times fromList<>, then we get one instance of the object.If you do a text file or xml , it seems like a long time. I would like to find the easiest option. But if this is the easiest option, then tell me, then I will answer what happened. With regard to SQLite , the more long fence, not worth it.
If you use Moki , it is embarrassing that I have almost no experience with them, and the fact that the data (for example, name, Email) will not look beautiful. It seems that in my situation it is easier to enter somehow the data for 5-10 users.
UPDATE: It is enough to save the state within one session of the program. After it is turned off, you can reset the added or modified User s