WPF and MVVM: Test Driven Development of ViewModels
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
- Introduction 2m
- Unit Testing Basics 4m
- Effective Unit Tests Are F.I.R.S.T. 3m
- Popular Unit Testing Frameworks for .NET 2m
- Write and Run a Unit Test with MSTest 5m
- Write and Run a Unit Test with xUnit 5m
- Parameterized Unit Tests with xUnit 5m
- Good Structure of a Unit Test 1m
- Adding a Test-project to FriendStorage 4m
- Test Driven Development (TDD) Basics 1m
- Using Spikes in TDD 2m
- Spiking the Navigation of FriendStorage 7m
- Testing the Load-method of the NavigationViewModel 3m
- Summary 2m
- Introduction 1m
- Dependencies of a ViewModel 1m
- Abstract Away Dependencies with Interfaces 2m
- Introduce the INavigationDataProvider-interface 3m
- Write Unit Tests with a NavigationDataProviderMock 5m
- Implement the Production NavigationDataProvider 4m
- Optimize the Code for Performance 6m
- Test the MainViewModel's Load-method 6m
- Dependency Injection Basics 3m
- Use Autofac to Inject Dependencies in FriendStorage 7m
- Summary 2m
- Introduction 2m
- Overview of Loading Friends in FriendStorage 2m
- Create the OpenFriendEditViewEvent 2m
- Add the NavigationItemViewModel 5m
- Add the IEventAggregator 3m
- Test and Publish the OpenFriendEditViewEvent 5m
- Open a Tab in the MainViewModel 5m
- Write the Test to Open the Tab 7m
- Implement the Logic to Open the Tab 2m
- Open Just One Tab Per Friend 6m
- Test the PropertyChanged-event 5m
- Load the Friend in the FriendEditViewModel 6m
- Implement the FriendEditViewModel 3m
- Adjust Autofac and Run FriendStorage 4m
- Summary 1m
- Introduction 2m
- Close a Tab 6m
- Enable and Disable the Save-button 4m
- Track Changes in a FriendWrapper 7m
- Raise the SaveCommand's CanExecuteChanged-event 4m
- Implement the SaveCommand to Save a Friend 4m
- Publish the FriendSavedEvent After Save 6m
- Refresh the Navigation After Save 6m
- Raise the PropertyChanged-event for the DisplayMember-property 7m
- Summary 1m
- Introduction 1m
- Create the AddFriendCommand in the MainViewModel 2m
- The Plan for the AddFriendCommand 3m
- Test the AddFriendCommand 5m
- Implement the AddFriendCommand 2m
- Refactor the MainViewModel 2m
- Create a New Friend in the FriendEditViewModel 4m
- Add the Saved Friend to the Navigation 6m
- Summary 2m