Unit Testing Xamarin Forms View Model

In this tutorial, we are going to see how to unit test a view model in a Xamarin Forms application.

View Model in a Nutshell

The view model is the centerpiece of the Model-View-ViewModel pattern. When you're not using MVVM, your presentation logic is in the view (code behind), making harder to test because the logic is coupled to UI elements. On the other hand, when using MVVM, your presentation logic move into the view model, by decoupling logic from the view, you gain the ability to test logic without being bothered by UI elements.

Getting Started

To walk you through this tutorial, I created a Xamarin Forms app called WorkoutTube.

Register and Login Using SQLite in Xamarin.Forms

Introduction

This article demonstrates how to register, login, and update the user data in SQLite. We perform CRUD operations with SQLite DB in Xamarin.Forms and can easily store and retrieve objects from the local database.

Output:

Image title