I'm trying to use FakeXrmEasy to run some unit tests for CRM Online (2016), and I'm having trouble setting up one of my tests with an N: N ratio
The following code sets up a fake context with two objects in it and initializes the Faked Organization service:
var entity1 = new New_entityOne(); var entity2 = new New_entityTwo(); var context = new XrmFakedContext(); context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(New_entityOne)); context.Initialize(new List<Entity>() { entity1, entity2 }); var service = context.GetFakedOrganizationService();
Then I try to create an N: N relation between these objects:
var join = new AssociateRequest { Relationship = new Relationship { SchemaName = "new_entityOne_new_entityTwo", PrimaryEntityRole = EntityRole.Referenced }, Target = entity1.ToEntityReference(), RelatedEntities = new EntityReferenceCollection { entity2.ToEntityReference() } }; service.Execute(join);
When I execute this Request , I expect that an N: N-join record will be created in my layout data between entity1 and entity2
Instead, I get an error message:
An exception of type "System.Exception" occurred in FakeXrmEasy.dll but was not handled in user code
Additional Information: The relationship new_entityOne_new_entityTwo does not exist in the metadata cache
Has anyone else tried to use this device infrastructure this way? Until now, I have been getting really good results using it.
obviously these are not my actual names of entities and relationships
unit-testing dynamics-crm-2016 dynamics-crm-online
jasonscript
source share