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

Object reference not set to an instance of an object. #607

Open sybaris opened 8 months ago

sybaris commented 8 months ago

Describe the bug An exception "Object reference not set to an instance of an object" is thrown when using a particular fetchxml

To Reproduce The following code reproduce the issue

[TestMethod]
        public void TestIssue()
        {
            string fetchxml = @"
                <fetch xmlns:generator='MarkMpn.SQL4CDS'>
                  <entity name='solutioncomponent'>

                    <attribute name='solutionid' />

                    <link-entity name='solutioncomponentdefinition' to='componenttype' from='objecttypecode' alias='solutioncomponentdefinition' link-type='outer'>
                      <attribute name='name' alias='solutioncomponentdefinitionname'/>
                      <attribute name='solutioncomponentdefinitionid' />
                    </link-entity>
                    <filter>

<condition attribute = 'name' entityname='solutioncomponentdefinition' operator='not-in'>
<value>AppSetting</value>
<value>AppElement</value>
</condition>

                    </filter>
                  </entity>
                </fetch>

";

            var context = MiddlewareBuilder
            .New()
            .AddCrud()
            .AddFakeMessageExecutors()
            .AddFakeMessageExecutors(Assembly.GetAssembly(typeof(RetrieveVersionRequestExecutor)))
            .AddGenericFakeMessageExecutors(Assembly.GetAssembly(typeof(NavigateToNextEntityOrganizationRequestExecutor)))
            .UseCrud()
            .UseMessages()
            .SetLicense(FakeXrmEasyLicense.RPL_1_5)
            .Build();
            context.EnableProxyTypes(Assembly.GetExecutingAssembly());
            context.InitializeMetadata(Assembly.GetExecutingAssembly());

            context.GetOrganizationService().RetrieveMultiple(new FetchExpression(fetchxml));
        }

Expected behavior No exception, and get the result Note that if you remove the condition block in the xml part, the unit test is green...

FakeXrmEasy and Dynamics 365 / CRM version 2.3.3