<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Unit Testing GetEntitiesAsync</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Unit Testing GetEntitiesAsync</description>
  <pubDate>Wed, 10 Jun 2026 20:54:46 -700</pubDate>
  <lastBuildDate>Wed, 07 Jan 2009 11:51:43 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1040</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Unit Testing GetEntitiesAsync : Thanks Kim. I&amp;#039;ll give that...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3785#3785</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=138" rel="nofollow">kid_kaneda</a><br /><strong>Subject:</strong> 1040<br /><strong>Posted:</strong> 07-Jan-2009 at 11:51am<br /><br />Thanks Kim. I'll give that a try]]>
   </description>
   <pubDate>Wed, 07 Jan 2009 11:51:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3785#3785</guid>
  </item> 
  <item>
   <title>Unit Testing GetEntitiesAsync : You can unit test async calls...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3762#3762</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1040<br /><strong>Posted:</strong> 31-Dec-2008 at 6:28pm<br /><br />You can unit test async calls in MSTest or NUnit, etc, it just takes a little extra effort.&nbsp; The error you see is the PersistenceManager complaining about a thread synchronization problem which you can work around.<DIV>&nbsp;</DIV><DIV>The easiest, although possibly not the most robust, way to solve the problem is to set the appropriate SynchronizationContext at the beginning of your test (or in a test or class initializer), like so:</DIV><DIV><FONT color=#2b91af size=2><FONT color=#2b91af size=2></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#2b91af size=2><FONT color=#2b91af size=2>&nbsp;&nbsp; SynchronizationContext</FONT></FONT><FONT size=2> sc = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> System.Windows.Forms.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>WindowsFormsSynchronizationContext</FONT></FONT><FONT size=2>();</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp; System.Windows.Forms.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>WindowsFormsSynchronizationContext</FONT></FONT><FONT size=2>.SetSynchronizationContext(sc);</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Once set, you can then issue async calls from your test method without the PM throwing an exception.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>Our own unit test suite for the framework actually uses a more complex (and possibly convoluted) approach to async unit testing which involves creating a&nbsp;form for each test.</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>&nbsp;</DIV></FONT>]]>
   </description>
   <pubDate>Wed, 31 Dec 2008 18:28:57 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3762#3762</guid>
  </item> 
  <item>
   <title>Unit Testing GetEntitiesAsync : GetEntitiesAsynch expects to be...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3758#3758</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=23" rel="nofollow">davidklitzke</a><br /><strong>Subject:</strong> 1040<br /><strong>Posted:</strong> 31-Dec-2008 at 9:11am<br /><br />GetEntitiesAsynch expects to be run in an Environment where there is a main UI thread and the GetEntitiesAsynch thread is spawned by the main UI thread.&nbsp; Normally, this is done by running your application as a Windows Forms Application, but the error message indicates that if you are using a Console or WindowsService application, you&nbsp;must use BeginInvoke and EndInvoke mechanisms instead.&nbsp; Alternatively, you might might be able to write your unit test application as a Windows Forms Application. <span style="font-size:10px"><br /><br />Edited by davidklitzke - 31-Dec-2008 at 9:15am</span>]]>
   </description>
   <pubDate>Wed, 31 Dec 2008 09:11:22 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3758#3758</guid>
  </item> 
  <item>
   <title>Unit Testing GetEntitiesAsync : Hi  I&amp;#039;m trying to write...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3756#3756</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=138" rel="nofollow">kid_kaneda</a><br /><strong>Subject:</strong> 1040<br /><strong>Posted:</strong> 31-Dec-2008 at 3:21am<br /><br /><DIV>Hi</DIV><DIV>&nbsp;</DIV><DIV>I'm trying to write a unit test which gets data asynchronously using <FONT size=2>GetEntitiesAsync().&nbsp; When I run this under MSTest I get the following exception (including the xxx at the beginning):</FONT></DIV><DIV>&nbsp;</DIV><DIV>"xxxAsync methods can only be called from applications running in a SynchronizationContext that supports thread synchronization. This means, in general, applications running in a WinForms or ASP.NET environment.&nbsp; Console or WindowsService applications must use BeginInvoke and EndInvoke mechanisms instead" </DIV><DIV>&nbsp;</DIV><DIV>Does this mean the async calls to the PersistenceManager cannot be tested?</DIV><DIV>&nbsp;</DIV><DIV>Thanks</DIV><DIV>&nbsp;</DIV><DIV>Kaneda</DIV>]]>
   </description>
   <pubDate>Wed, 31 Dec 2008 03:21:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1040&amp;PID=3756#3756</guid>
  </item> 
 </channel>
</rss>