15,861,168 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Articles / Desktop Programming / WPF
Go to Article
Stats
Revisions (8)
C#
XML
.NET
WPF
MVVM
Catel - Part 4 of n: Unit testing with Catel
Geert van Horrik
Rate me:
Please
Sign up or sign in
to vote.
4.55/5 (10 votes)
28 Jan 2011
CPOL
11 min read
48.5K
572
11
This article explains how to write unit tests for MVVM using Catel.
catel-04_01-unittesting.zip
src
Catel.Articles.04 - Unit testing.Test
App.config
Catel.Articles.04 - Unit testing.Test.csproj
Models
PersonTest.cs
Properties
AssemblyInfo.cs
UI
ViewModels
MainWindowViewModelTest.cs
Catel.Articles.04 - Unit testing
App.xaml
App.xaml.cs
Catel.Articles.04 - Unit testing.csproj
Models
Person.cs
Properties
AssemblyInfo.cs
Resources.Designer.cs
Resources.resx
Settings.Designer.cs
Settings.settings
Resources
Images
add.png
delete.png
edit.png
group.png
UI
Data
Converters
GenderToIsSelectedConverter.cs
ViewModels
MainWindowViewModel.cs
PersonViewModel.cs
Windows
MainWindow.xaml
MainWindow.xaml.cs
PersonWindow.xaml
PersonWindow.xaml.cs
Catel.Articles.Base
Catel.Articles.Base.csproj
Data
Attributes
ExampleAttribute.cs
ExampleInfo.cs
ThemeInfo.cs
Properties
AssemblyInfo.cs
Resources.Designer.cs
Resources.resx
Settings.Designer.cs
Settings.settings
Resources
Images
CatenaLogic.png
Preview.png
Run.png
ShowCode.png
UI
Controls
ExampleControl.xaml
ExampleControl.xaml.cs
Helpers
ExampleHelper.cs
ViewModels
ExamplesViewModel.cs
ExampleViewModel.cs
Windows
ControlExampleWindow.xaml
ControlExampleWindow.xaml.cs
ExamplesWindow.xaml
ExamplesWindow.xaml.cs
Catel.Core
Attributes
CoverageExcludeAttribute.cs
Catel.Core.csproj
ClassDiagrams
DataObjectBase.cd
SavableDataObjectBase.cd
Collections
Helpers
CollectionHelper.cs
ComponentModel
IDataWarningInfo.cs
Data
Attributes
AllowNonSerializableMembersAttribute.cs
DataObjectBase.cs
Exceptions
InvalidPropertyException.cs
InvalidPropertyValueException.cs
PropertyAlreadyRegisteredException.cs
PropertyNotNullableException.cs
PropertyNotRegisteredException.cs
Interfaces
IDataObjectBase.cs
IParent.cs
ISavableDataObjectBase.cs
PropertyData.cs
PropertyDataManager.cs
SavableDataObjectBase.cs
Diagnostics
Extensions
ExceptionExtensions.cs
Helpers
TraceHelper.cs
OutputTraceListener.cs
TraceListenerBase.cs
Enum.cs
Exceptions
NotSupportedInSilverlightException.cs
Helpers
AssemblyHelper.cs
AttributeHelper.cs
TypeHelper.cs
IO
Directory.cs
Exceptions
CannotCreateDirectoryException.cs
File.cs
FileWatcher.cs
Path.cs
Win32IOApi.cs
IoC
UnityContainer.cs
LLBLGen
LLBLGenExtensions.cs
LLBLGenHelper.cs
Log4net
Appender
TraceAppenderEx.cs
Extensions
Log4netExtensions.cs
Helpers
Log4netHelper.cs
MVVM
Commands
Interfaces
ICatelCommand.cs
Exceptions
InvalidViewModelException.cs
ModelNotRegisteredException.cs
PropertyNotFoundInModelException.cs
ViewModelNotRegisteredException.cs
WrongViewModelTypeException.cs
Services
EventArgs
UICompletedEventArgs.cs
Exceptions
WindowNotRegisteredException.cs
Interfaces
IFileSupport.cs
IMessageService.cs
IOpenFileService.cs
IPleaseWaitService.cs
ISaveFileService.cs
IUIVisualizerService.cs
IViewModelService.cs
ViewModelServiceBase.cs
ViewModelServiceManager.cs
ViewModels
Attributes
InterestedInAttribute.cs
ModelAttribute.cs
ViewModelToModelAttribute.cs
Interfaces
IViewModel.cs
IViewModelContainer.cs
ManagedViewModel.cs
ViewModelBaseWithoutServices.cs
ViewModelManager.cs
Properties
AssemblyInfo.cs
Exceptions.Designer.cs
Exceptions.resx
Exceptions.Silverlight.Designer.cs
Resources.Designer.cs
Resources.nl-NL.Designer.cs
Resources.nl-NL.resx
Resources.nl-NL.Silverlight.Designer.cs
Resources.resx
Resources.Silverlight.Designer.cs
SharedAssemblyInfo.cs
TraceMessages.Designer.cs
TraceMessages.resx
TraceMessages.Silverlight.Designer.cs
Reflection
Exceptions
CannotGetPropertyValueException.cs
CannotSetPropertyValueException.cs
PropertyNotFoundException.cs
Extensions
AppDomainExtensions.cs
AssemblyExtensions.cs
ReflectionExtensions.cs
Helpers
PropertyHelper.cs
PropertySorter.cs
RetrySafetyCounter.cs
Runtime
Serialization
Attributes
RedirectTypeAttribute.cs
Helpers
SerializationHelper.cs
RedirectDeserializationBinder.cs
Security
Cryptography
Helpers
CryptHelper.cs
Catel.Examples.Models
Catel.Examples.Models.csproj
Family.cs
Person.cs
Properties
AssemblyInfo.cs
Catel.Examples.PersonApplication
app.config
App.xaml
App.xaml.cs
Catel.Examples.PersonApplication.csproj
Properties
AssemblyInfo.cs
Resources.Designer.cs
Resources.resx
Settings.Designer.cs
Settings.settings
Resources
Images
add.png
delete.png
edit.png
group.png
UI
Data
Converters
GenderToIsSelectedConverter.cs
ViewModels
MainWindowViewModel.cs
PersonViewModel.cs
Windows
MainWindow.xaml
MainWindow.xaml.cs
PersonWindow.xaml
PersonWindow.xaml.cs
StackGridSampleWindow.xaml
StackGridSampleWindow.xaml.cs
Catel.Examples.Silverlight.Web
Catel.Examples.Silverlight.Web.csproj
Catel.Examples.Silverlight.Web.csproj.user
Catel.Examples.SilverlightTestPage.aspx
Catel.Examples.SilverlightTestPage.html
ClientBin
Properties
AssemblyInfo.cs
Silverlight.js
Web.config
Web.Debug.config
Web.Release.config
Catel.Examples.Silverlight
App.xaml
App.xaml.cs
Catel.Examples.Silverlight.csproj
Properties
AppManifest.xml
AssemblyInfo.cs
Resources.Designer.cs
Resources.resx
Resources
Images
add.png
delete.png
edit.png
group.png
UI
Data
Converters
GenderToIsSelectedConverter.cs
Pages
MainPage.xaml
MainPage.xaml.cs
ViewModels
MainPageViewModel.cs
PersonViewModel.cs
Windows
PersonWindow.xaml
PersonWindow.xaml.cs
Catel.FxCop
Catel.Silverlight.Test.Web
Catel.Silverlight.Test.Web.csproj
Catel.Silverlight.Test.Web.csproj.user
Catel.Silverlight.TestTestPage.aspx
Catel.Silverlight.TestTestPage.html
ClientBin
Properties
AssemblyInfo.cs
Silverlight.js
Web.config
Web.Debug.config
Web.Release.config
Catel.Silverlight.Test
App.xaml
App.xaml.cs
Catel.Silverlight.Test.csproj
Properties
AppManifest.xml
AssemblyInfo.cs
Catel.Silverlight
Catel.Silverlight.csproj
Diagnostics
Stopwatch.cs
log4net
Core
ILogger.cs
ILoggerWrapper.cs
DummyLog.cs
ILog.cs
LogManager.cs
MVVM
Commands
Services
MessageService.cs
OpenFileService.cs
PleaseWaitService.cs
SaveFileService.cs
UIVisualizerService.cs
ViewModels
Properties
AssemblyInfo.cs
Catel.Core
Catel.Windows
Exceptions.Designer.cs
Exceptions.resx
Resources.Designer.cs
Resources.nl-NL.resx
Resources.resx
TraceMessages.Designer.cs
TraceMessages.resx
Reflection
Pointer.cs
Themes
Generic.xaml
Generic
Assets
catel.sizes.normal.xaml
InfoBarMessageControl.generic.xaml
Old
catel.generic.xaml
generic.xaml
Windows
Controls
ValidationResult.cs
ValidationRule.cs
Data
Converters
Helpers
Helpers
LogicalTreeHelper.cs
Catel.sln
Catel.snk
Catel.Templates.WpfApplication
app.config
App.xaml
App.xaml.cs
Catel.Templates.WpfApplication.csproj
Properties
AssemblyInfo.cs
Resources.Designer.cs
Resources.resx
Settings.Designer.cs
Settings.settings
UI
Controls
ViewModels
MainWindowViewModel.cs
Windows
MainWindow.xaml
MainWindow.xaml.cs
Catel.Templates.WpfItemTemplates
Catel.Templates.WpfItemTemplates.csproj
Properties
AssemblyInfo.cs
UI
Controls
UserControl.xaml
UserControl.xaml.cs
ViewModels
DataWindowViewModel.cs
UserControlViewModel.cs
Windows
DataWindow.xaml
DataWindow.xaml.cs
Catel.Test
Catel.Test.csproj
Collections
CollectionHelperTest.cs
ObservableCollectionExtensionsTest.cs
Convert
ConvertTest.cs
Data
DataObjectBaseTest.cs
DataObjectBaseTestHelper.cs
PropertyDataManagerTest.cs
PropertyDataTest.cs
SavableDataObjectBaseTest.cs
EnumTest.cs
Helpers
AttributeHelperTest.cs
FilesHelper.cs
LLBLGenHelperTest.cs
TypeHelperTest.cs
WindowHelper.cs
IO
DirectoryTest.cs
FileTest.cs
PathTest.cs
MVVM
UI
ControlToViewModelAttributeTest.cs
ControlToViewModelMappingContainerTest.cs
ControlToViewModelMappingHelperTest.cs
ControlToViewModelMappingTest.cs
ViewModels
ViewModelBaseTest.cs
Properties
AssemblyInfo.cs
Reflection
AppDomainExtensionsTest.cs
AssemblyExtensionsTest.cs
PropertyHelperTest.cs
ReflectionExtensionsTest.cs
RetrySafetyCounterTest.cs
Runtime
Serialization
SerializationHelperTest.cs
Security
Cryptography
CryptHelperTest.cs
Test References
Catel.Windows.accessor
Windows
Data
Converters
AreEqualMultiValueConverterTest.cs
BooleanToGrayscaleConverterTest.cs
BooleanToOppositeBooleanConverterTest.cs
BooleanToTextConverterTest.cs
BooleanToVisibilityConverterTest.cs
ColorToBrushConverterTest.cs
ContainsItemsConverterTest.cs
CountVisibilityConverterTest.cs
EmptyStringToVisibilityConverterTest.cs
FormattingConverterTest.cs
GetFirstValidationErrorConverterTest.cs
IsSelectedConverterTest.cs
IsSelectedValueConverterTest.cs
MethodToValueConverterTest.cs
MultiplyConverterTest.cs
ReferenceToBooleanConverterTest.cs
ReferenceToCollapsingVisibilityConverterTest.cs
ShortDateFormattingConverterTest.cs
Catel.vsmdi
Catel.Windows
Catel.Windows.csproj
ClassDiagrams
ViewModelBase.cd
Collections
Extensions
ObservableCollectionExtensions.cs
Constants.cs
Helpers
PathHelper.cs
MVVM
Commands
Command.cs
EventToCommand.cs
Services
MessageService.cs
OpenFileService.cs
PleaseWaitService.cs
SaveFileService.cs
Test
MessageService.cs
OpenFileService.cs
PleaseWaitService.cs
SaveFileService.cs
UIVisualizerService.cs
UIVisualizerService.cs
UI
ControlToViewModelAttribute.cs
ControlToViewModelMapping.cs
ControlToViewModelMappingContainer.cs
ControlToViewModelMappingHelper.cs
ViewModels
ViewModelBase.cs
Properties
AssemblyInfo.cs
Exceptions.Designer.cs
Exceptions.resx
Exceptions.Silverlight.Designer.cs
Resources.Designer.cs
Resources.nl-NL.Designer.cs
Resources.nl-NL.resx
Resources.nl-NL.Silverlight.Designer.cs
Resources.resx
Resources.Silverlight.Designer.cs
Settings.Designer.cs
Settings.settings
TraceMessages.Designer.cs
TraceMessages.resx
TraceMessages.Silverlight.Designer.cs
Resources
Images
Add.png
ClearOutput.png
Edit.png
Error.png
Loading.gif
Preview.png
Remove.png
Save.png
TipOfTheDay.png
Warning.png
Themes
Aero
catel.aero.large.xaml
catel.aero.normal.xaml
generic.xaml
ExpressionDark
Assets
CatelAdditions.xaml
ExpressionDark.xaml
catel.expressiondark.large.xaml
catel.expressiondark.normal.xaml
generic.xaml
readme.txt
Generic.xaml
Generic
Assets
catel.generic.xaml
catel.sizes.large.xaml
catel.sizes.normal.xaml
catel.large.xaml
catel.normal.xaml
Controls
InfoBarMessageControl.generic.xaml
LinkLabel.generic.xaml
InfoBarMessageControl.generic.xaml
Jetpack
Assets
background.png
Brushes.xaml
CatelAdditions.xaml
CoreStyles.xaml
Fonts.xaml
SDKStyles.xaml
Styles.xaml
catel.jetpack.large.xaml
catel.jetpack.normal.xaml
generic.xaml
readme.txt
LinkLabel.Generic.xaml
Old
catel.generic.xaml
catel.normal.xaml
generic.xaml
readme.txt
SunnyOrange
Assets
SunnyOrange_Theme.xaml
catel.sunnyorange.large.xaml
catel.sunnyorange.normal.xaml
generic.xaml
readme.txt
Windows
Controls
AnimatedGif.cs
BrowseForFile.xaml
BrowseForFile.xaml.cs
DropDownButton.cs
Extensions
RichTextBoxExtensions.cs
InfoBarMessageControl.cs
LinkLabel
BindableRun.cs
LinkLabel.cs
LinkLabelBehavior.cs
LinkLabelClickBehavior.cs
MultiLineInput.xaml
MultiLineInput.xaml.cs
RadioButtonEx.cs
RichToolTip.cs
ScrollViewerProperties.cs
StackGrid
EmptyColumn.cs
EmptyRow.cs
StackGrid.cs
ToggleRadioButton.xaml
ToggleRadioButton.xaml.cs
TraceOutputControl.xaml
TraceOutputControl.xaml.cs
UserControl.cs
VisualWrapper.cs
WarningAndErrorValidator.cs
Data
Converters
AreEqualMultiValueConverter.cs
BooleanToGrayscaleConverter.cs
BooleanToOppositeBooleanConverter.cs
BooleanToTextConverter.cs
BooleanToVisibilityConverter.cs
ColorToBrushConverter.cs
ContainsItemsConverter.cs
CountVisibilityConverter.cs
EmptyStringToVisibilityConverter.cs
FormattingConverter.cs
GetFirstValidationErrorConverter.cs
Helpers
ConverterHelper.cs
IsSelectedConverter.cs
IsSelectedValueConverter.cs
MethodToValueConverter.cs
MultiplyConverter.cs
NullableValueConverter.cs
OutputTypeConverter.cs
ReferenceToBooleanConverter.cs
ReferenceToVisibilityConverter.cs
RoutedUICommandToContentConverter.cs
RoutedUICommandToToolTipConverter.cs
ShortDateFormattingConverter.cs
StringToIntConverter.cs
ValueConverterGroup.cs
VisibilityConverterBase.cs
DataResource.cs
TipOfTheDayData.cs
Documents
DataFormats.cs
Extensions
FlowDocumentExtensions.cs
TextRangeExtensions.cs
Rtf.cs
Sizes.cs
Extensions
ApplicationExtensions.cs
DependencyObjectExtensions.cs
FrameWorkElementExtensions.cs
UIElementExtensions.cs
VisualExtensions.cs
WindowExtensions.cs
Helpers
AutoDisposeHelper.cs
Dispatcherhelper.cs
ModalWindowHelper.cs
StyleHelper.cs
ValidationHelper.cs
VisualTargetPresentationSource.cs
WrapControlHelper.cs
Input
BrowseForFileCommands.cs
DataCommands.cs
NavigationCommands.cs
TipOfTheDayCommands.cs
WindowCommands.cs
Markup
AppDomainTypeResolver.cs
BamlAssembly.cs
BamlBinaryReader.cs
BamlFile.cs
BamlRecordType.cs
DotNetType.cs
IDependencyPropertyDescriptor.cs
IType.cs
ITypeResolver.cs
KnownInfo.cs
PropertyDeclaration.cs
ResourceName.cs
TypeDeclaration.cs
WpfDependencyPropertyDescriptor.cs
XamlTypeResolver.cs
XmlBamlElement.cs
XmlBamlNode.cs
XmlBamlProperty.cs
XmlBamlPropertyElement.cs
XmlBamlReader.cs
XmlBamlText.cs
XmlNamespace.cs
XmlPIMapping.cs
Media
Effects
EmptyEffect.fx
EmptyEffect
EmptyEffect.cs
EmptyEffect.fx
EmptyEffect.ps
GrayscaleEffect
GrayscaleEffect.cs
GrayscaleEffect.fx
GrayscaleEffect.ps
ShaderEffectBase.cs
Extensions
ImageSourceExtensions.cs
VisualExtensions.cs
Imaging
Extensions
BitmapExtensions.cs
Windows
DataWindow
DataWindow.cs
DataWindowButton.cs
LoaderAnimation.xaml
LoaderAnimation.xaml.cs
MultiLineInputWindow.xaml
MultiLineInputWindow.xaml.cs
MultipleChoiceWindow.xaml
MultipleChoiceWindow.xaml.cs
PleaseWaitWindow.xaml
PleaseWaitWindow.xaml.cs
TipOfTheDay
TipOfTheDayEditorWindow.xaml
TipOfTheDayEditorWindow.xaml.cs
TipOfTheDayItemEditorWindow.xaml
TipOfTheDayItemEditorWindow.xaml.cs
TipOfTheDayWindow.xaml
TipOfTheDayWindow.xaml.cs
TraceOutputWindow.xaml
TraceOutputWindow.xaml.cs
CustomDictionary.xml
Local.testsettings
Settings.StyleCop
TraceAndTestImpact.testsettings