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));
}
20. [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);
}
Model => domain object. the actual data/information. Example: contact (name, phone number, address)
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
Let op met service calls of andere externe afhankelijkheden. Dit zijn Integration Tests.
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
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
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
Client is equal for Publisher and Ratings.
Show the demo project running for a sec
Demo of the various attributes and different unit tests.
[Tag]
[Description]
[Asynchronous]
[Bug]
[WorkItem]
[TimeOut]
[ExpectedException]
Silverlight = asynchronous
Many asynchronous tests
Tests ends when EnqueueTestComplete is called
To demonstrate -> uncomment // Thread.Sleep(TimeSpan.FromSeconds(5)); in TestPublishersDataService
Demo of statlight
Running commandline single and continuous
Sixin Meeting (9 nov) about Designer-Developer lifecycle and userstories