<?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 : CompositionContext.Fake and Login</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : CompositionContext.Fake and Login</description>
  <pubDate>Wed, 29 Jul 2026 18:43:53 -700</pubDate>
  <lastBuildDate>Wed, 06 Apr 2011 14:37:19 -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=2586</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>CompositionContext.Fake and Login : Dennis,Thanks for the help on...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10404#10404</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=888" rel="nofollow">robert.hui</a><br /><strong>Subject:</strong> 2586<br /><strong>Posted:</strong> 06-Apr-2011 at 2:37pm<br /><br />Dennis,<div><br></div><div>Thanks for the help on that. Something very similar to that appears to have worked on my end.</div>]]>
   </description>
   <pubDate>Wed, 06 Apr 2011 14:37:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10404#10404</guid>
  </item> 
  <item>
   <title>CompositionContext.Fake and Login :  Hi robert.hui;If I understand...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10299#10299</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2586<br /><strong>Posted:</strong> 28-Mar-2011 at 1:39pm<br /><br />Hi robert.hui;<div><br></div><div>If I understand your question correctly, I believe you can accomplish what you want with IEntityServerFakeBackingStore.RestoreAsync operation.</div><div><br></div><div>The idea is to populate a real EntityManager's cache with some Users data and allow a fake EntityManager to import that cache to its own cache thus populating the fake EntityManager with some data.</div><div><br></div><div>Please see code snippets below.</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp;public void PopulateFakeEmWithUsersBeforeLogin() {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var fakeEm = new NorthwindIBEntityManager(compositionContextName: CompositionContext.Fake.Name);&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var coop = Coroutine.Start( () =&gt; PopulateWithUsersCore(fakeEm) );</div><div>&nbsp;&nbsp; &nbsp; &nbsp;coop.Completed += (s, args) =&gt; {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var isSuccessful = args.CompletedSuccessfully;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var error = args.Error;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;fakeEm.Users.ExecuteAsync(op =&gt; {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var isSuccessful2 = op.CompletedSuccessfully;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var error2 = op.Error;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var list = new List&lt;User&gt;(op.Results);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;});</div><div>&nbsp;&nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp;private IEnumerable&lt;INotifyCompleted&gt; PopulateWithUsersCore(NorthwindIBEntityManager fakeEm) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var realEm = new NorthwindIBEntityManager();</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var fakeBackingStore = fakeEm.CompositionContext.GetFakeBackingStore();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;//Populate realEm cache with Users</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var query = realEm.Users;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var queryOp = query.ExecuteAsync();</div><div>&nbsp;&nbsp; &nbsp; &nbsp;queryOp.Completed += (s, args) =&gt; {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var isSuccessful = args.CompletedSuccessfully;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var error = args.Error;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var users = new List&lt;User&gt;(args.Results);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp;yield return queryOp;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;//Populate fakeEm with realEM cache</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var realEmCacheState = realEm.CacheStateManager.GetCacheState();</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var restoreOp = fakeBackingStore.RestoreAsync(realEmCacheState);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;restoreOp.Completed += (s, args) =&gt; {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var isSuccessful = args.CompletedSuccessfully;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;var error = args.Error;</div><div>&nbsp;&nbsp; &nbsp; &nbsp;};</div><div>&nbsp;&nbsp; &nbsp; &nbsp;yield return restoreOp;</div><div>&nbsp;&nbsp; &nbsp;}</div></div><span style="font-size:10px"><br /><br />Edited by DenisK - 28-Mar-2011 at 1:55pm</span>]]>
   </description>
   <pubDate>Mon, 28 Mar 2011 13:39:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10299#10299</guid>
  </item> 
  <item>
   <title>CompositionContext.Fake and Login : I have a question about how to...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10294#10294</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=888" rel="nofollow">robert.hui</a><br /><strong>Subject:</strong> 2586<br /><strong>Posted:</strong> 25-Mar-2011 at 3:39pm<br /><br /><div style=": rgb255, 255, 255; margin-left: 1px; margin-top: 1px; margin-right: 1px; margin-bottom: 1px; font-family: Verdana, Arial, Helvetica, sans-serif; color: rgb0, 0, 0; font-weight: normal; font-size: 12px; line-height: 1.4; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; -: n&#111;ne; ">I have a question about how to use the CompositionContext.Fake. I read over the DRC documentation on faking:&nbsp;http://drc.ideablade.com/xwiki/bin/view/Documentation/discovery-compositioncontext-fake, but it only covered a simple case where no Login credentials were required.<div><br></div><div>I'm trying to set up a fake context for use in unit tests, by inflating an in-memory database to run some of our queries. I'm running into a chicken and egg problem with our login process, though.</div><div><br></div><div>By default, the first login to the BOS is a LoginCredential. This allows the user to read back a list of users (in our UI, this let's us show a dropdown). All other access is locked down until a user logs in with credentials. My question is, how do I inject fake user data into the system *before* log in, so that I can authenticate against credentials in the DB?</div><div><br></div><div>Is this even possible (via a RestoreCacheState, for example)?</div><div><br></div><div>Thanks,</div><div>Rob</div></div>]]>
   </description>
   <pubDate>Fri, 25 Mar 2011 15:39:11 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2586&amp;PID=10294#10294</guid>
  </item> 
 </channel>
</rss>