Simple play icon Course
Skills

WPF and MVVM: Test Driven Development of ViewModels

by Thomas Claudius Huber

Testing your ViewModels while they're in development can help you create better apps. In this course, you'll learn how to use test-driven development (TDD) to build the ViewModels of your MVVM application.

What you'll learn

When applying the MVVM pattern, the UI-logic is placed in ViewModels. A key advantage of such a ViewModel is that it is highly testable. In this course, WPF and MVVM: Test Driven Development of ViewModels, you'll learn the specifics of unit testing within MVVM. You'll discover how to create and run unit tests in Visual Studio with the popular testing framework xUnit, and how to write testable ViewModels by moving out typical dependencies like data access logic, event aggregator, modal dialogs and more. Next, you'll be taught how to mock/fake these dependencies in your unit tests by using the mocking library, Moq, as well as inject the dependencies into your ViewModels with a dependency injection framework called Autofac while running your application. Finally, you'll build and unit-test the ViewModels for an MVVM app called FriendStorage from 'empty class' to final by using test-driven development. By the end of this course, you'll understand how to develop your ViewModels through testing in order to create better apps than ever.

Table of contents

Course Overview
1min

About the author

Thomas is a Microsoft MVP for Windows Development. He works as a developer, consultant, and trainer in the fields of .NET, C#, TypeScript, XAML, and Azure. Thomas is a well-known speaker and book author. He has written several special interest books in his areas, including an extensive handbook for Windows Presentation Foundation and a handbook on development with TypeScript. Thomas lives in Germany's Black Forest with his wife and their three daughters. In his spare time, he plays football and ... more

Ready to upskill? Get started