Visual Basic (Declaration) | |
---|---|
Public Shared Fake As CompositionContext |
Visual Basic (Usage) | ![]() |
---|---|
Dim value As CompositionContext value = CompositionContext.Fake CompositionContext.Fake = value |
C# | |
---|---|
public static CompositionContext Fake |
C++/CLI | |
---|---|
public: static CompositionContext^ Fake |
C# | ![]() |
---|---|
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(); } |
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.
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