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
Post a Comment