Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Model-View-ViewModel in WPF

, 21 Dec 2007
An article on creating WPF applications, following the Model-View-ViewModel pattern
codeproject.zip
CodeProject
.bzr
.bzrignore
branch
branch-format
branch-lock
branch-name
format
lock
revision-history
checkout
conflicts
dirstate
format
lock
README
repository
format
inventory.kndx
inventory.knit
knits
01
assemblyinfo.cs-20071213013430-sngkh9ui5e83ud60-8.kndx
assemblyinfo.cs-20071213013430-sngkh9ui5e83ud60-8.knit
tasklist.datamodel-20071213014434-wjgek8uvcjo8yp5s-1.kndx
tasklist.datamodel-20071213014434-wjgek8uvcjo8yp5s-1.knit
08
properties-20071213014434-wjgek8uvcjo8yp5s-3.kndx
properties-20071213014434-wjgek8uvcjo8yp5s-3.knit
0a
taskcollectiontest.c-20071213180529-6351e013ut030x8d-1.kndx
taskcollectiontest.c-20071213180529-6351e013ut030x8d-1.knit
10
tasklist.viewmodel-20071213212525-zmxqp3frjbsg0b0z-1.kndx
tasklist.viewmodel-20071213212525-zmxqp3frjbsg0b0z-1.knit
15
itasklistapplication-20071213212525-zmxqp3frjbsg0b0z-3.kndx
itasklistapplication-20071213212525-zmxqp3frjbsg0b0z-3.knit
16
resources.designer.c-20071213035543-53ny0xm8ahdeup8a-3.kndx
resources.designer.c-20071213035543-53ny0xm8ahdeup8a-3.knit
19
assemblyinfo.cs-20071213213342-s7iwkoswpulzwbg4-5.kndx
assemblyinfo.cs-20071213213342-s7iwkoswpulzwbg4-5.knit
1b
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-10.kndx
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-10.knit
27
commandsinkattribute-20071214020122-tzvrpu3a2hvv9ioh-1.kndx
commandsinkattribute-20071214020122-tzvrpu3a2hvv9ioh-1.knit
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-1.kndx
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-1.knit
2a
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-4.kndx
test.tasklist.viewmo-20071213213342-s7iwkoswpulzwbg4-4.knit
2c
tasklistviewmodel.cs-20071213213222-558xu0jc4awt8fgg-1.kndx
tasklistviewmodel.cs-20071213213222-558xu0jc4awt8fgg-1.knit
32
selection.cs-20071215202735-qp5k90odcm8iomjv-1.kndx
selection.cs-20071215202735-qp5k90odcm8iomjv-1.knit
38
testdataerrorinfo.cs-20071213023410-3b817j85lvxslkns-1.kndx
testdataerrorinfo.cs-20071213023410-3b817j85lvxslkns-1.knit
3a
tasklistcommands.cs-20071215160037-lz7a3je7txcjyri5-1.kndx
tasklistcommands.cs-20071215160037-lz7a3je7txcjyri5-1.knit
3c
edittaskpage.xaml-20071215212433-9gnk5rr3mjw0gjrf-1.kndx
edittaskpage.xaml-20071215212433-9gnk5rr3mjw0gjrf-1.knit
properties-20071213013430-sngkh9ui5e83ud60-6.kndx
properties-20071213013430-sngkh9ui5e83ud60-6.knit
3f
taskcollection.cs-20071213181230-6z9ws0p8k1vkjzuc-1.kndx
taskcollection.cs-20071213181230-6z9ws0p8k1vkjzuc-1.knit
40
mainwindowviewmodelt-20071213213449-ns60l2kj4h237pzg-1.kndx
mainwindowviewmodelt-20071213213449-ns60l2kj4h237pzg-1.knit
41
edittaskpage.xaml.cs-20071215212433-9gnk5rr3mjw0gjrf-2.kndx
edittaskpage.xaml.cs-20071215212433-9gnk5rr3mjw0gjrf-2.knit
45
globalsuppressions.c-20071217043309-o86x25nntk0bk6lo-1.kndx
globalsuppressions.c-20071217043309-o86x25nntk0bk6lo-1.knit
4c
globalsuppressions.c-20071213211235-souqg3uilzehioee-1.kndx
globalsuppressions.c-20071213211235-souqg3uilzehioee-1.knit
4e
localtestrun.testrun-20071213013430-sngkh9ui5e83ud60-2.kndx
localtestrun.testrun-20071213013430-sngkh9ui5e83ud60-2.knit
4f
precondition.cs-20071213022255-ecv7q7up7nar12vq-1.kndx
precondition.cs-20071213022255-ecv7q7up7nar12vq-1.knit
51
codeproject.snk-20071213021143-3x1ioaofarxdc7k2-2.kndx
codeproject.snk-20071213021143-3x1ioaofarxdc7k2-2.knit
54
properties-20071213213342-s7iwkoswpulzwbg4-3.kndx
properties-20071213213342-s7iwkoswpulzwbg4-3.knit
57
tasktest.cs-20071213013555-48d7c3agymuoj2i0-1.kndx
tasktest.cs-20071213013555-48d7c3agymuoj2i0-1.knit
58
assemblyinfo.cs-20071213021143-3x1ioaofarxdc7k2-5.kndx
assemblyinfo.cs-20071213021143-3x1ioaofarxdc7k2-5.knit
5e
iedittaskpageview.cs-20071217021058-4xiyah3s4mh60qow-1.kndx
iedittaskpageview.cs-20071217021058-4xiyah3s4mh60qow-1.knit
61
assemblyinfo.cs-20071213022943-ws0x3cedbvac5k3p-5.kndx
assemblyinfo.cs-20071213022943-ws0x3cedbvac5k3p-5.knit
67
codeprojectcore.cspr-20071213021143-3x1ioaofarxdc7k2-3.kndx
codeprojectcore.cspr-20071213021143-3x1ioaofarxdc7k2-3.knit
6d
tasklistpageviewmode-20071215194732-4g7n1tutd5u4iig0-4.kndx
tasklistpageviewmode-20071215194732-4g7n1tutd5u4iig0-4.knit
71
codeproject.sln-20071213013011-q70xfq7n7ogllazi-1.kndx
codeproject.sln-20071213013011-q70xfq7n7ogllazi-1.knit
76
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-1.kndx
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-1.knit
79
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-4.kndx
test.codeprojectcore-20071213022943-ws0x3cedbvac5k3p-4.knit
7f
authoringtests.txt-20071213013430-sngkh9ui5e83ud60-4.kndx
authoringtests.txt-20071213013430-sngkh9ui5e83ud60-4.knit
codeprojectcore-20071213021143-3x1ioaofarxdc7k2-1.kndx
codeprojectcore-20071213021143-3x1ioaofarxdc7k2-1.knit
86
resources.resx-20071213013237-ucb9omrtgj50gglg-16.kndx
resources.resx-20071213013237-ucb9omrtgj50gglg-16.knit
8a
bzrignore-20071213012954-kvrppfyxdd192lwi-1.kndx
bzrignore-20071213012954-kvrppfyxdd192lwi-1.knit
8d
resources.resx-20071213211717-wf3kh2bgsnduzgg4-12.kndx
resources.resx-20071213211717-wf3kh2bgsnduzgg4-12.knit
90
viewmodel.cs-20071214020122-tzvrpu3a2hvv9ioh-2.kndx
viewmodel.cs-20071214020122-tzvrpu3a2hvv9ioh-2.knit
93
codeproject.snk-20071213013237-ucb9omrtgj50gglg-3.kndx
codeproject.snk-20071213013237-ucb9omrtgj50gglg-3.knit
94
properties-20071213021143-3x1ioaofarxdc7k2-4.kndx
properties-20071213021143-3x1ioaofarxdc7k2-4.knit
95
tasklist.datamodel.c-20071213014434-wjgek8uvcjo8yp5s-4.kndx
tasklist.datamodel.c-20071213014434-wjgek8uvcjo8yp5s-4.knit
97
stringlengthvalidato-20071213035543-53ny0xm8ahdeup8a-2.kndx
stringlengthvalidato-20071213035543-53ny0xm8ahdeup8a-2.knit
98
authoringtests.txt-20071213213342-s7iwkoswpulzwbg4-2.kndx
authoringtests.txt-20071213213342-s7iwkoswpulzwbg4-2.knit
9c
properties-20071213022943-ws0x3cedbvac5k3p-3.kndx
properties-20071213022943-ws0x3cedbvac5k3p-3.knit
9f
codeproject.snk-20071213211717-wf3kh2bgsnduzgg4-4.kndx
codeproject.snk-20071213211717-wf3kh2bgsnduzgg4-4.knit
a5
resources.designer.c-20071213013237-ucb9omrtgj50gglg-15.kndx
resources.designer.c-20071213013237-ucb9omrtgj50gglg-15.knit
tasklist.viewmodel.c-20071213212525-zmxqp3frjbsg0b0z-5.kndx
tasklist.viewmodel.c-20071213212525-zmxqp3frjbsg0b0z-5.knit
a6
tasklisttestapplicat-20071213214943-dyyzzbvhjnv2ggob-1.kndx
tasklisttestapplicat-20071213214943-dyyzzbvhjnv2ggob-1.knit
ac
resources.designer.c-20071213211717-wf3kh2bgsnduzgg4-11.kndx
resources.designer.c-20071213211717-wf3kh2bgsnduzgg4-11.knit
ae
specify.cs-20071213013237-ucb9omrtgj50gglg-12.kndx
specify.cs-20071213013237-ucb9omrtgj50gglg-12.knit
af
imainwindowview.cs-20071214025649-nyfq33grd351tyuj-1.kndx
imainwindowview.cs-20071214025649-nyfq33grd351tyuj-1.knit
b1
mainwindow.xaml-20071213211717-wf3kh2bgsnduzgg4-5.kndx
mainwindow.xaml-20071213211717-wf3kh2bgsnduzgg4-5.knit
b2
app.xaml-20071213211717-wf3kh2bgsnduzgg4-2.kndx
app.xaml-20071213211717-wf3kh2bgsnduzgg4-2.knit
b3
tasklist.csproj.user-20071213211717-wf3kh2bgsnduzgg4-9.kndx
tasklist.csproj.user-20071213211717-wf3kh2bgsnduzgg4-9.knit
b4
codeproject.snk-20071213212525-zmxqp3frjbsg0b0z-2.kndx
codeproject.snk-20071213212525-zmxqp3frjbsg0b0z-2.knit
frameworkmessages.cs-20071213013237-ucb9omrtgj50gglg-6.kndx
frameworkmessages.cs-20071213013237-ucb9omrtgj50gglg-6.knit
b6
mainwindow.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-6.kndx
mainwindow.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-6.knit
b7
app.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-3.kndx
app.xaml.cs-20071213211717-wf3kh2bgsnduzgg4-3.knit
settings.designer.cs-20071213211717-wf3kh2bgsnduzgg4-13.kndx
settings.designer.cs-20071213211717-wf3kh2bgsnduzgg4-13.knit
bc
assemblyinfo.cs-20071213212525-zmxqp3frjbsg0b0z-6.kndx
assemblyinfo.cs-20071213212525-zmxqp3frjbsg0b0z-6.knit
bd
app.config-20071215154029-mlxydmaa3bclnaag-1.kndx
app.config-20071215154029-mlxydmaa3bclnaag-1.knit
be
edittaskpageviewmode-20071215212433-9gnk5rr3mjw0gjrf-3.kndx
edittaskpageviewmode-20071215212433-9gnk5rr3mjw0gjrf-3.knit
c0
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-1.kndx
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-1.knit
c1
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-2.kndx
codeproject.visualst-20071213013237-ucb9omrtgj50gglg-2.knit
c2
tasklistpageviewmode-20071215200239-p788d71fwwxauwrm-1.kndx
tasklistpageviewmode-20071215200239-p788d71fwwxauwrm-1.knit
c5
commandtester.cs-20071214020412-lzl7v3k2q5et9xoj-1.kndx
commandtester.cs-20071214020412-lzl7v3k2q5et9xoj-1.knit
specificationvalue.c-20071213013237-ucb9omrtgj50gglg-11.kndx
specificationvalue.c-20071213013237-ucb9omrtgj50gglg-11.knit
tasklist.csproj-20071213211717-wf3kh2bgsnduzgg4-8.kndx
tasklist.csproj-20071213211717-wf3kh2bgsnduzgg4-8.knit
c6
codeproject.snk-20071213014434-wjgek8uvcjo8yp5s-2.kndx
codeproject.snk-20071213014434-wjgek8uvcjo8yp5s-2.knit
c9
assemblyinfo.cs-20071213013237-ucb9omrtgj50gglg-14.kndx
assemblyinfo.cs-20071213013237-ucb9omrtgj50gglg-14.knit
ca
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-4.kndx
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-4.knit
cb
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-5.kndx
collectionchangedwat-20071213013237-ucb9omrtgj50gglg-5.knit
cc
testextensions.cs-20071213013237-ucb9omrtgj50gglg-13.kndx
testextensions.cs-20071213013237-ucb9omrtgj50gglg-13.knit
cd
assemblyinfo.cs-20071213014434-wjgek8uvcjo8yp5s-5.kndx
assemblyinfo.cs-20071213014434-wjgek8uvcjo8yp5s-5.knit
codeproject.vsmdi-20071213013430-sngkh9ui5e83ud60-1.kndx
codeproject.vsmdi-20071213013430-sngkh9ui5e83ud60-1.knit
d0
assemblyinfo.cs-20071213211717-wf3kh2bgsnduzgg4-10.kndx
assemblyinfo.cs-20071213211717-wf3kh2bgsnduzgg4-10.knit
d2
mainwindowviewmodel.-20071214021535-pfu4qerfstp78gcd-1.kndx
mainwindowviewmodel.-20071214021535-pfu4qerfstp78gcd-1.knit
d4
manualtest1.mht-20071213013430-sngkh9ui5e83ud60-5.kndx
manualtest1.mht-20071213013430-sngkh9ui5e83ud60-5.knit
settings.settings-20071213211717-wf3kh2bgsnduzgg4-14.kndx
settings.settings-20071213211717-wf3kh2bgsnduzgg4-14.knit
d6
task.cs-20071213014820-kfzciheohayefljq-1.kndx
task.cs-20071213014820-kfzciheohayefljq-1.knit
d9
properties-20071213013237-ucb9omrtgj50gglg-8.kndx
properties-20071213013237-ucb9omrtgj50gglg-8.knit
de
itasklistpageview.cs-20071215201802-5gm7npkr8rynfbpn-1.kndx
itasklistpageview.cs-20071215201802-5gm7npkr8rynfbpn-1.knit
e0
authoringtests.txt-20071213022943-ws0x3cedbvac5k3p-2.kndx
authoringtests.txt-20071213022943-ws0x3cedbvac5k3p-2.knit
e3
dataerrorinfo.cs-20071213023841-9p8uxe73oezcfbdz-1.kndx
dataerrorinfo.cs-20071213023841-9p8uxe73oezcfbdz-1.knit
properties-20071213211717-wf3kh2bgsnduzgg4-7.kndx
properties-20071213211717-wf3kh2bgsnduzgg4-7.knit
ea
tasklistpage.xaml-20071215194732-4g7n1tutd5u4iig0-1.kndx
tasklistpage.xaml-20071215194732-4g7n1tutd5u4iig0-1.knit
ed
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-3.kndx
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-3.knit
ef
tasklistpage.xaml.cs-20071215194732-4g7n1tutd5u4iig0-2.kndx
tasklistpage.xaml.cs-20071215194732-4g7n1tutd5u4iig0-2.knit
f1
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-7.kndx
test.tasklist.datamo-20071213013430-sngkh9ui5e83ud60-7.knit
f3
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-9.kndx
propertychangedwatch-20071213013237-ucb9omrtgj50gglg-9.knit
f4
objectextensions.cs-20071213035543-53ny0xm8ahdeup8a-1.kndx
objectextensions.cs-20071213035543-53ny0xm8ahdeup8a-1.knit
f5
numerics.cs-20071213013237-ucb9omrtgj50gglg-7.kndx
numerics.cs-20071213013237-ucb9omrtgj50gglg-7.knit
f7
properties-20071213212525-zmxqp3frjbsg0b0z-4.kndx
properties-20071213212525-zmxqp3frjbsg0b0z-4.knit
resources.resx-20071213035543-53ny0xm8ahdeup8a-4.kndx
resources.resx-20071213035543-53ny0xm8ahdeup8a-4.knit
f9
validatorattribute.c-20071213025856-7hxu8ce3k2040pyr-1.kndx
validatorattribute.c-20071213025856-7hxu8ce3k2040pyr-1.knit
fe
titleconverter.cs-20071215194732-4g7n1tutd5u4iig0-3.kndx
titleconverter.cs-20071215194732-4g7n1tutd5u4iig0-3.knit
ff
tasklist-20071213211717-wf3kh2bgsnduzgg4-1.kndx
tasklist-20071213211717-wf3kh2bgsnduzgg4-1.knit
lock
revision-store
revisions.kndx
revisions.knit
signatures.kndx
signatures.knit
CodeProject.VisualStudio.QualityTools.UnitTestFramework
bin
Debug
CodeProject.snk
Properties
CodeProject.vsmdi
CodeProjectCore
bin
Debug
CodeProject.snk
Properties
LocalTestRun.testrunconfig
TaskList
TaskList.DataModel
bin
Debug
CodeProject.snk
Properties
TaskList.ViewModel
bin
Debug
CodeProject.snk
Properties
bin
Debug
TaskList.vshost.exe
TaskList.vshost.exe.manifest
CodeProject.snk
Properties
Settings.settings
TaskList.csproj.user
Test.CodeProjectCore
bin
Debug
Properties
Test.TaskList.DataModel
bin
Debug
Properties
Test.TaskList.ViewModel
bin
Debug
Properties
==========================================================================
    Visual Studio Team System: Overview of Authoring and Running Tests    
==========================================================================

This overview describes the features for authoring and running tests in 
Visual Studio Team System and Visual Studio Team Edition for Software Testers.

Opening Tests
-------------
To open a test, open a test project or a test metadata file (a file with
extension .vsmdi) that contains the definition of the test. You can find
test projects and metadata files in Solution Explorer.

Viewing Tests
-------------
To see which tests are available to you, open the Test View window. Or,
if you have installed Team Edition for Software Testers, you can also open
the Test List Editor window to view tests.

To open the Test View window, click the Test menu, point to Windows, and
then click Test View. To open the Test List Editor window (if you have
installed Team Edition for Software Testers), click Test, point to Windows,
and then click Test List Editor.

Running Tests
-------------
You can run tests from the Test View window and the Test List Editor window.
See Viewing Tests to learn how to open these windows. To run one or more
tests displayed in the Test View window, first select the tests in that
window; to select multiple tests, hold either the Shift or CTRL key while
clicking tests. Then click the Run Tests button in the Test View window
toolbar.

If you have installed Visual Studio Team Edition for Software Testers, you can
also use the Test List Editor window to run tests. To run tests in Test List Editor,
select the check box next to each test that you want to run. Then click the
Run Tests button in the Test List Editor window toolbar.

Viewing Test Results
--------------------
When you run a test or a series of tests, the results of the test run will be
shown in the Test Results window. Each individual test in the run is shown on
a separate line so that you can see its status. The window contains an
embedded status bar in the top half of the window that provides you with
summary details of the complete test run.

To see more detailed results for a particular test result, double-click it in
the Test Results window. This opens a window that provides more information
about the particular test result, such as any specific error messages returned
by the test.

Changing the way that tests are run
-----------------------------------
Each time you run one or more tests, a collection of settings is used to
determine how those tests are run. These settings are contained in a “test
run configuration” file.

Here is a partial list of the changes you can make with a test run 
configuration file:

 - Change the naming scheme for each test run.
 - Change the test controller that the tests are run on so that you can run
   tests remotely.
 - Gather code coverage data for the code being tested so that you can see
   which lines of code are covered by your tests.
 - Enable and disable test deployment. 
 - Specify additional files to deploy before tests are run.
 - Select a different host, ASP.NET, for running ASP.NET unit tests.
 - Select a different host, the smart device test host, for running smart device unit tests.
 - Set various properties for the test agents that run your tests.
 - Run custom scripts at the start and end of each test run so that you can
   set up the test environment exactly as required each time tests are run.
 - Set time limits for tests and test runs.
 - Set the browser mix and the number of times to repeat Web tests in the
   test run.

By default, a test run configuration file is created whenever you create a
new test project. You make changes to this file by double-clicking it in 
Solution Explorer and then changing its settings. (Test run configuration
files have the extension .testrunconfig.)

A solution can contain multiple test run configuration files. Only one of
those files, known as the “Active” test run configuration file, is used to
determine the settings that are currently used for test runs. You select
the active test run configuration by clicking Select Active Test Run 
Configuration on the Test menu.

-------------------------------------------------------------------------------

Test Types
----------
Using Visual Studio Team Edition for Software Testers, you can create a number
of different test types:

Unit test: Use a unit test to create a programmatic test in C++, Visual C# or
Visual Basic that exercises source code. A unit test calls the methods of a
class, passing suitable parameters, and verifies that the returned value is
what you expect.
There are three specialized variants of unit tests:
 - Data-driven unit tests are created when you configure a unit test to be
   called repeatedly for each row of a data source. The data from each row
   is used by the unit test as input data.
 - ASP.NET unit tests are unit tests that exercise code in an ASP.NET Web
   application.
 - Smart device unit tests are unit tests that are deployed to a smart device
   or emulator and then executed by the smart device test host.  

Web Test: Web tests consist of an ordered series of HTTP requests that you
record in a browser session using Microsoft Internet Explorer. You can have
the test report specific details about the pages or sites it requests, such
as whether a particular page contains a specified string.

Load Test: You use a load test to encapsulate non-manual tests, such as
unit, Web, and generic tests, and then run them simultaneously by using
virtual users. Running these tests under load generates test results,
including performance and other counters, in tables and in graphs.

Generic test: A generic test is an existing program wrapped to function as a
test in Visual Studio. The following are examples of tests or programs that
you can turn into generic tests:
 - An existing test that uses process exit codes to communicate whether the
   test passed or failed. 0 indicates passing and any other value indicates
   a failure.
 - A general program to obtain specific functionality during a test scenario.
 - A test or program that uses a special XML file (called a “summary results
   file”), to communicate detailed results.

Manual test: The manual test type is used when the test tasks are to be
completed by a test engineer as opposed to an automated script.

Ordered test: Use an ordered test to execute a set of tests in an order you
specify.

-------------------------------------------------------------------------------


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

William E. Kempf
Web Developer
United States United States
Windows developer with 10+ years experience working in the banking industry.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 22 Dec 2007
Article Copyright 2007 by William E. Kempf
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid