Writing a mock web service
Many times when developing a mobile application, you may need to begin the development of your application before the real backend web service is available. To prevent the development from halting entirely, a good approach would be to develop a mock version of the service. This is also helpful when you need to write unit tests, or are waiting on another team to develop the backend for your app.
First, let's break down the operations our app will perform against a web server. The operations are as follows:
Login with a username and password.
Register a new account.
Get the user's list of friends.
Add friends by their usernames.
Get a list of the existing conversations for the user.
Get a list of messages in a conversation.
Send a message.
Now let's define an interface that offers a method for each scenario. The method is as follows:
public interface IWebService { Task<User> Login(string userName, string password); Task<User> Register...