Winter 19 release provides ability to instantiate the custom metadata in apex .This seems to be useful to generate data for test classes .
However when we have metadata relationship entity or field entity relationship the QualifiedName comes as null in Test class .
Lets take an example with the below code in a Test class .For now use execute Anonymous via Dev console
Relationship__mdt relationship = new Relationship__mdt( DeveloperName = 'Test', Active__c = true, Object__c = 'Account', AccountRelationship__c = 'ParentId' ); system.debug('###'+relationship.Object__r.qualifiedAPIName);
In the above code Object__c is of type metadataRelationship (Object definition ) and AccountRelationship__c is also of metadataRelationship type (Field Entity Definition) .
When i do
relationship.Object__r.QualifiedAPIName in test context I receive null and not 'Account'.
Similarly when i do
relationship.AccountRelationship__r.QualifiedAPIName in test context I receive null and not ParentId .
This makes it not helpful again for use cases where metadata data has entity relationship and the code uses QualifiedName .
Is it a bug or I am overlooking something ?