Silverlight Unit Test The platform has the [AsynchronousAttribute] attribute, which causes the tests to end only when EnqueueTestComplete () is called. This allows you to use a simple way to write tests that need to wait for an event to finish. Now Iām trying to choose from the very beginning the most suitable variant of Unit Test, which looks the most popular - VSUTF, NUnit, xUnit.NET, MbUnit, and I was wondering how you will conduct asynchronous testing using these frameworks
I suppose I can release some custom code that Monitor.Wait or ResetEventWaitOne will do and call it at the end of the test method, and then execute Pulse / Set when the test is finished, but I looked, is an existing general / inline solution .
This is an example of how this is done in SUT (from http://smartypantscoding.com/a-cheat-sheet-for-unit-testing-silverlight-apps-on-windows-phone-7 ).
[TestClass] public class AsyncTests : SilverlightTest { [Asynchronous] [TestMethod] public void AsyncAppendStringTest() { var appendStrings = new List<string>() { "hello", "there" }; StringJoiner.AsyncAppendStringsWithDashes(appendStrings, (returnString) => { Assert.IsTrue(string.Compare(returnString, "hello-there") == 0); EnqueueTestComplete(); }); } }
Filip skakun
source share