c# - MsTest with Task.ContinueWith() and Task.Wait()...? -


i'm still in .net 4.0 , wondering whether pattern hold in various kinds of async unit testing situations:

/// <summary> /// noaa weather test: should read remote xml. /// </summary> [testmethod] public void shouldreadremotexml() {     var uri = new uri("http://www.weather.gov/xml/current_obs/klax.xml");     var wait = httpverbasyncutility.getasync(uri)         .continuewith(         t =>         {             assert.isfalse(t.isfaulted, "an unexpected xml read error has occurred.");             assert.istrue(t.iscompleted, "the expected xml read did not take place.");              if(t.iscompleted && !t.isfaulted)                 frameworkfileutility.write(t.result, @"noaaweather.xml");         })         .wait(timespan.fromseconds(7));      assert.istrue(wait, "the expected xml read did not take place within 7 seconds."); } 

will task.continuewith()...task.wait() pattern hold in real world? i'm relatively new formally thinking unit testing (especially asynchronous unit testing) please don't hold on basics :)

unit test frameworks typically not work out of box asynchronous code, of great concern adding await c# , visual basic.

typically happens test method hits first "await", returns. test marked having succeeded because returned without errors, if errors going produced in continuation.

we're working unit test framework providers improve story upcoming version of visual studio. mstest , xunit.net handle async methods in vs 11 beta. advice is: ahold of vs 11 beta , try out asynchronous unit testing support in it. if not it, now great time give feedback on async forum.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -