jordimontana82 / fake-xrm-easy

The testing framework for Dynamics CRM and Dynamics 365 which runs on an In-Memory context and deals with mocks or fakes for you
https://dynamicsvalue.com/get-started/overview?source=git
Other
263 stars 182 forks source link

ConditionOperator.Null is not working in a nested filter using FakeXrmEasy version newer than v1.51.1 #547

Open vmarsen opened 3 years ago

vmarsen commented 3 years ago

I was trying to write a unit test using a nested filter with ConditionOperator.Null using the latest version of FakeXrmEasy.9 (currently is this v1.57.1). I noticed that the test was not working because of the ConditionOperator.Null in the nestedfilter. Once I downgrade the FakeXrmEasy.9 version to v.1.51.0, the test was successfully. In all later versions the test will fail.

In my program, there are 2 Entities: Person and Employment. An employment is linked to a person and has a startdate/enddate. Here is the query, I am using: var query = new QueryExpression { EntityName = Person.EntityLogicalName, LinkEntities = { new LinkEntity { LinkFromEntityName = Person.EntityLogicalName, LinkFromAttributeName = Person.AttributeLogicalNames.Id, LinkToEntityName = Employment.EntityLogicalName, LinkToAttributeName = Employment.AttributeLogicalNames.PersonId, JoinOperator = JoinOperator.Inner, EntityAlias = Employment.EntityLogicalName, Columns = new ColumnSet( Employment.AttributeLogicalNames.Id, Employment.AttributeLogicalNames.StartDate ), LinkCriteria = new FilterExpression { Filters = { new FilterExpression(LogicalOperator.And) { Conditions = { new ConditionExpression(Employment.AttributeLogicalNames.EndDate, ConditionOperator.Null) } } } } } } };

I expect that a person with an employment with an empty enddate (enddate is null) will be filtered, but the test fails. There are no results when retrieving this query.

The file with the demo code can be found here. There, you will see that the test is not working. If you downgrade the project to FakeXrmEasy.9 to version 1.51.0, then you will see that the test is successfully.

FakeXrmEasy versions: 1.50.0 => works successfully 1.51.0 => works successfully 1.51.1 => Not working anymore 1.51.2 => Not working anymore All later versions => Not working anymore

jordimontana82 commented 3 years ago

Thanks @vmarsen .

May I ask what's the version of the CRM SDK you're using to check?

Cheers

GeusB commented 3 years ago

We are currently using 9.0.2.23 nugets

jordimontana82 commented 3 years ago

Thanks for reporting