Presentation is loading. Please wait.

Presentation is loading. Please wait.

Timmy Kokke Silverlight / ASP.Net Developer UNIT4 Internet Solutions Expression Blend MVP.

Similar presentations


Presentation on theme: "Timmy Kokke Silverlight / ASP.Net Developer UNIT4 Internet Solutions Expression Blend MVP."— Presentation transcript:

1 Timmy Kokke Silverlight / ASP.Net Developer UNIT4 Internet Solutions Expression Blend MVP

2 Basics of MVVM Unit Testing Silverlight Unit Testing framework StatLight

3 ModelModel ViewView ViewModelViewModel

4 ModelModel ViewView ViewModelViewModel

5 ModelModel ViewView ViewModelViewModel

6 ModelModel ViewView ViewModelViewModel

7 ModelModel ViewView ViewModelViewModel Databinding Commands Methods Events

8 Unit tests are consistent, isolated, fast and repeatable

9 Test only small units of work TestName = Requirement 1 Assert per test Self explanatory Readability over Maintainability

10 Silverlight Toolkit Runs in browser, no support for MsTest

11

12 [TestClass] public class ExampleTests{ [TestMethod] public class Adding_1_And_1_Should_Be_2(){ int result = 1 + 1; Assert.AreEqual(2, result); }

13 ServerServer Silverlight Client GamesViewModelGamesViewModel GamesViewGamesView GamesDataServiceGamesDataService WCF Ria Service DatabaseDatabase

14

15 Unit Test ServerServer Silverlight Client GamesViewModelGamesViewModel GamesViewGamesView GamesDataServiceGamesDataService WCF Ria Service DatabaseDatabase TestGamesDataServiceTestGamesDataService IGamesDataServiceIGamesDataService GamesViewModelTestsGamesViewModelTests

16

17 [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); }

18 [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)); }

19 [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); }

20 [TestMethod] [Bug("Submitting is not implemented at this moment.")] [WorkItem(1543)] [Asynchronous] public void Executing_SubmitCommand_Should_Navigate_To_GamesList() { DecoupledEventAggregator.GetInstance().GetEvent ().Subscribe((a) => { Assert.IsTrue(true); EnqueueTestComplete(); }); RatingViewModel viewModel = new RatingViewModel(new TestGamesDataService()); viewModel.SubmitCommand.Execute(null); }

21 [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); }

22 [TestMethod] [ExpectedException(typeof(ArgumentNullException))] public void Executing_SubmitCommand_With_Null_Should_Throw_Exception() { RatingViewModel viewModel = new RatingViewModel(new TestGamesDataService()); viewModel.SubmitCommand.Execute(null); }

23 Command line tool Possible to integrate in TFS build Continuous mode

24

25 Timmy Kokke Silverlight and Expression Usergroup 9 November next meeting !


Download ppt "Timmy Kokke Silverlight / ASP.Net Developer UNIT4 Internet Solutions Expression Blend MVP."

Similar presentations


Ads by Google