IdeaBlade DevForce 2010 Help Reference
Fake Field
See Also  Example Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core.Composition Namespace > CompositionContext Class : Fake Field



The "fake" composition context.

Syntax

Visual Basic (Declaration) 
Public Shared Fake As CompositionContext
Visual Basic (Usage)Copy Code
Dim value As CompositionContext
 
value = CompositionContext.Fake
 
CompositionContext.Fake = value
C# 
public static CompositionContext Fake
C++/CLI 
public:
static CompositionContext^ Fake

Example

C#Copy Code
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 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.