DevForce Help Reference
Fake Field
Example 


The "fake" composition context.
Syntax
'Declaration
 
Public Shared Fake As CompositionContext
'Usage
 
Dim value As CompositionContext
 
value = CompositionContext.Fake
 
CompositionContext.Fake = value
public static CompositionContext Fake
Example
public void SampleTestWithFakes() {

   // Sample showing use of the Fake composition context.
   // All queries and saves are processed by the EntityServerFakeBackingStore.
   var em = new DomainModelEntityManager(compositionContextName: CompositionContext.Fake.Name);

   // Create and save a new entity.
   var cust = new Customer() { CompanyName = "TestCo", Address = "123 Elm St" };
   em.AddEntity(cust);
   em.SaveChanges();

   // Clear the EM cache.
   em.Clear();

   // Now query from the "server" - in this case the EntityServerFakeBackingStore.
   var customers = em.Customers.ToList();
}
Remarks
The Fake context will filter for "fake" implementations of exported types. Any implementation which provides export metadata setting "IsFake" to true will be used by the Fake context. For example, the FakeIdGenerator is an implementation of the IIdGenerator interface which can be used to provide fake Id generation during testing.

The Fake context uses the EntityServerFakeBackingStore as its backing store, and uses fake query and save executors (note these are not the same thing as the EntityServerQueryInterceptor and EntityServerSaveInterceptor) to perform standard DevForce query and save processing against a fake backing store.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CompositionContext Class
CompositionContext Members

Send Feedback