SlideShare a Scribd company logo
Timmy Kokke
Silverlight / ASP.Net Developer
UNIT4 Internet Solutions
Expression Blend MVP
Basics of MVVM
Unit Testing
Silverlight Unit Testing framework
StatLight
Model
View
ViewModel
Model
View
ViewModel
Model
View
ViewModel
Model
View
ViewModel
Model
View
ViewModel
Databinding
Commands
Methods
Events
Unit tests are
consistent, isolated, fast and repeatable
Test only small units of work
TestName = Requirement
1 Assert per test
Self explanatory
Readability over Maintainability
Silverlight Toolkit
http://silverlight.codeplex.com
Runs in browser, no support for MsTest
Unit testing and MVVM in Silverlight
[TestClass]
public class ExampleTests{
[TestMethod]
public class Adding_1_And_1_Should_Be_2(){
int result = 1 + 1;
Assert.AreEqual(2, result);
}
}
ServerSilverlightClient
GamesViewModel
GamesView
GamesDataService
WCF Ria Service
Database
Unit testing and MVVM in Silverlight
UnitTest
ServerSilverlightClient
GamesViewModel
GamesView
GamesDataService
WCF Ria Service
Database
TestGamesDataService
IGamesDataService
GamesViewModelTests
Unit testing and MVVM in Silverlight
[TestMethod]
[Tag("Rating")]
public void Setting_Ratings_Should_Set_AverageRating()
{
Rating rating = new Rating();
rating.GameplayRating = 4;
rating.GraphicsRating = 2;
Assert.AreEqual(3, rating.AverageRating);
}
[TestMethod]
[Description("Testing implementation of IDataErrorInfo."+
"Empty String Name should return Error.")]
public void Getting_ErrorInfo_For_Empty_Name_Should_Return_Error()
{
Rating errorInfo = new Rating {Name = string.Empty};
string result = errorInfo["Name"];
Assert.IsFalse(string.IsNullOrWhiteSpace(result));
}
[TestMethod]
[Asynchronous]
public void Executing_InitializeCommand_Should_Get_Publishers()
{
PublishersViewModel viewModel = new PublishersViewModel(
new TestPublishersDataService());
viewModel.PropertyChanged += (s, a) =>
{
Assert.IsTrue(viewModel.Publishers != null);
EnqueueTestComplete();
};
viewModel.InitializeCommand.Execute(null);
}
[TestMethod]
[Bug("Submitting is not implemented at this moment.")]
[WorkItem(1543)]
[Asynchronous]
public void Executing_SubmitCommand_Should_Navigate_To_GamesList()
{
DecoupledEventAggregator.GetInstance()
.GetEvent<NavigateToEvent>().Subscribe((a) =>
{
Assert.IsTrue(true);
EnqueueTestComplete();
});
RatingViewModel viewModel =
new RatingViewModel(new TestGamesDataService());
viewModel.SubmitCommand.Execute(null);
}
[TestMethod]
[Asynchronous]
[Timeout(250)]
public void Executing_GetMoreCommand_Should_Respond_In_250ms()
{
PublishersViewModel viewModel =
new PublishersViewModel(new TestPublishersDataService());
viewModel.PropertyChanged += (s, a) =>
{
Assert.IsTrue(true);
EnqueueTestComplete();
};
viewModel.GetMoreCommand.Execute(null);
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void Executing_SubmitCommand_With_Null_Should_Throw_Exception()
{
RatingViewModel viewModel =
new RatingViewModel(new TestGamesDataService());
viewModel.SubmitCommand.Execute(null);
}
Command line tool
http://statlight.codeplex.com
Possible to integrate in TFS build
Continuous mode
Unit testing and MVVM in Silverlight
http://silverlight.codeplex.com
http://statlight.codeplex.com
Timmy Kokke
info@timmykokke.com
http://twitter.com/sorskoot
http://www.timmykokke.com
Silverlight and Expression Usergroup
http://www.sixin.nl
9 November next meeting !

More Related Content

PPT
Hybrid Automation Framework Development introduction
PPTX
Visual Studio 2010 for testers
DOCX
Testing in TFS
PDF
How to Build Your Own Test Automation Framework?
PPTX
Keyword-driven Test Automation Framework
PPTX
Full Testing Experience - Visual Studio and TFS 2010
PDF
Laws of test automation framework
PPTX
Overview of Visual Studio Team System 2010
Hybrid Automation Framework Development introduction
Visual Studio 2010 for testers
Testing in TFS
How to Build Your Own Test Automation Framework?
Keyword-driven Test Automation Framework
Full Testing Experience - Visual Studio and TFS 2010
Laws of test automation framework
Overview of Visual Studio Team System 2010

What's hot (18)

PPTX
STARWEST 2011 - 7 Steps To Improving Software Quality using Microsoft Test Ma...
PPT
Qtp With Descriptive Programming
PPTX
Team Foundation Server 2010 - Overview
PDF
Deployment automation framework with selenium
PPT
Automation framework
PPTX
Lab Management with TFS 2010
PPTX
A Test Automation Framework
PPTX
Visual Studio 2010 Testing Overview
PPTX
Silk Performer Presentation v1
PPT
upload ppt by browse button
PPT
Justin Presentation PPT Upload
PPT
Paper Ps
PPT
Paper Ps
PPT
justin presentation upload PPT june 19
PPT
alka ppt upload no code change
PPT
justin presentation upload PPT june 25 ADVANCED
PPT
Paper CS
STARWEST 2011 - 7 Steps To Improving Software Quality using Microsoft Test Ma...
Qtp With Descriptive Programming
Team Foundation Server 2010 - Overview
Deployment automation framework with selenium
Automation framework
Lab Management with TFS 2010
A Test Automation Framework
Visual Studio 2010 Testing Overview
Silk Performer Presentation v1
upload ppt by browse button
Justin Presentation PPT Upload
Paper Ps
Paper Ps
justin presentation upload PPT june 19
alka ppt upload no code change
justin presentation upload PPT june 25 ADVANCED
Paper CS
Ad

Viewers also liked (8)

PDF
Devnology Back to School III : Software impact
PDF
Devnology Back to School IV - Agility en Architectuur
PDF
DNSSec: Internet achter de schermen
PPT
Code inspecties
PDF
Meetup at SIG: Meten is weten
PPTX
Devnology Fitnesse workshop
PDF
Learn a language : LISP
PPTX
TechDaysNL 2015 - F# for C# Developers
Devnology Back to School III : Software impact
Devnology Back to School IV - Agility en Architectuur
DNSSec: Internet achter de schermen
Code inspecties
Meetup at SIG: Meten is weten
Devnology Fitnesse workshop
Learn a language : LISP
TechDaysNL 2015 - F# for C# Developers
Ad

Similar to Unit testing and MVVM in Silverlight (20)

PDF
Turbocharge Your Automation Framework to Shorten Regression Execution Time
PPT
Silverlight2 Unit Testing Slides
PDF
An introduction to unit testing
PPTX
Whats New In 2010 (Msdn & Visual Studio)
PPTX
Automated Testing Of EPiServer CMS Sites
PPTX
No More No Repro
PPTX
Evaluating Test Driven Development And Parameterized Unit Testing In Dot Net ...
PDF
Streamline Testing: Transition from Manual to Automation with Selenium & C#
PDF
Streamline Testing: Transition from Manual to Automation with Selenium & C#
PPT
Selenium
PPTX
Test driven development in .Net - 2010 + Eclipse
PDF
Test Automation Frameworks Using Selenium | Edureka
DOC
Kasi Resume
PPT
Justmeans power point
PPTX
Test automation within a scrum process
PPTX
Modeling and Testing Dovetail in MagicDraw
PPTX
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
PPTX
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
PPTX
Continuous performance testing
PPTX
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
Turbocharge Your Automation Framework to Shorten Regression Execution Time
Silverlight2 Unit Testing Slides
An introduction to unit testing
Whats New In 2010 (Msdn & Visual Studio)
Automated Testing Of EPiServer CMS Sites
No More No Repro
Evaluating Test Driven Development And Parameterized Unit Testing In Dot Net ...
Streamline Testing: Transition from Manual to Automation with Selenium & C#
Streamline Testing: Transition from Manual to Automation with Selenium & C#
Selenium
Test driven development in .Net - 2010 + Eclipse
Test Automation Frameworks Using Selenium | Edureka
Kasi Resume
Justmeans power point
Test automation within a scrum process
Modeling and Testing Dovetail in MagicDraw
Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Train...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Continuous performance testing
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...

More from Devnology (20)

PDF
What do we really know about the differences between static and dynamic types?
PDF
Software Operation Knowledge
PPTX
Slides Felienne Hermans Symposium EWI
PDF
Devnology auteursrecht en open source 20130205
PDF
The top 10 security issues in web applications
PDF
Hacking Smartcards & RFID
PDF
Learn a language : LISP
PDF
Devnology Back to School: Empirical Evidence on Modeling in Software Development
PDF
Devnology back toschool software reengineering
PDF
Introduction to Software Evolution: The Software Volcano
PPT
Devnology Workshop Genpro 2 feb 2011
PPT
Devnology Coding Dojo 05-01-2011
PDF
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
PDF
Experimenting with Augmented Reality
PDF
mobl: Een DSL voor mobiele applicatieontwikkeling
PDF
Rascal Devnology Code Fest
PPT
Building an artificial game player in Smalltalk
PPTX
Reverse Engineering Spreadsheets
ODP
Software Transactioneel Geheugen
PPTX
Codereviews
What do we really know about the differences between static and dynamic types?
Software Operation Knowledge
Slides Felienne Hermans Symposium EWI
Devnology auteursrecht en open source 20130205
The top 10 security issues in web applications
Hacking Smartcards & RFID
Learn a language : LISP
Devnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology back toschool software reengineering
Introduction to Software Evolution: The Software Volcano
Devnology Workshop Genpro 2 feb 2011
Devnology Coding Dojo 05-01-2011
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Experimenting with Augmented Reality
mobl: Een DSL voor mobiele applicatieontwikkeling
Rascal Devnology Code Fest
Building an artificial game player in Smalltalk
Reverse Engineering Spreadsheets
Software Transactioneel Geheugen
Codereviews

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Spectroscopy.pptx food analysis technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
A comparative analysis of optical character recognition models for extracting...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
“AI and Expert System Decision Support & Business Intelligence Systems”
Spectroscopy.pptx food analysis technology
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
Machine Learning_overview_presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A Presentation on Artificial Intelligence
The Rise and Fall of 3GPP – Time for a Sabbatical?

Unit testing and MVVM in Silverlight

Editor's Notes

  • #5: View => presentation of the data. Xaml
  • #6: ViewModel => the glue between View and Model.
  • #7: Model => domain object. the actual data/information. Example: contact (name, phone number, address)
  • #8: ViewModel -> Binding -> View -> Binding/Commands/Behaviors -> ViewModel ViewModel -> Method -> Model -> Events/Delegates -> ViewModel All client-server communication is async in Silverlight… makes testing a little more difficult. Testing mainly ViewModel… Sometimes a little View
  • #9: Let op met service calls of andere externe afhankelijkheden. Dit zijn Integration Tests.
  • #10: Test only small units of work TestName = Requirement 1 Assert per test Self explanatory Readability over Maintainability Naamgeving duidelijk -> underscores etc. Schrijf parameters als named parameters Vermijd dubbele code (DRY) -> gebruik functies als Make_GameViewModel
  • #11: Testframework is part of Silverlight toolkit Runs inside the browser, tools available to run from commandline (Statlight)… later more about this. Test classes can inherit from SilverlightTest -> Not supported in MSTest in visual studio (yet?) CodeCoverage is not available yet. Integratie in TFS build process wel mogelijk, via custom extension
  • #12: Start new Silverlight Project, add test project. Write some useless tests to demonstrate writing tests… Assert.AreEqual(1+1,3) Attributes: [TestClass] [TestMethod] 2e demo… Flow van attributes en test methoden… file importeren met example… breakpoints plaatsen [AssemblyInitialize] [AssemblyCleanup] -> 1x per assembly [ClassInitialize] [ClassCleanup] -> 1x per class [TestInitialize] [TestCleanup] -> 1x per test
  • #14: Client is equal for Publisher and Ratings.
  • #15: Show the demo project running for a sec
  • #17: Demo of the various attributes and different unit tests. [Tag] [Description] [Asynchronous] [Bug] [WorkItem] [TimeOut] [ExpectedException]
  • #20: Silverlight = asynchronous Many asynchronous tests Tests ends when EnqueueTestComplete is called
  • #22: To demonstrate -> uncomment // Thread.Sleep(TimeSpan.FromSeconds(5)); in TestPublishersDataService
  • #25: Demo of statlight Running commandline single and continuous
  • #26: Sixin Meeting (9 nov) about Designer-Developer lifecycle and userstories