You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
When a FetchXml aggregate includes a groupby clause on an optionset value then FakeXrmEasy will return incorrect results. The following unit tests is similar to other tests within AggregateTests.cs, except it is altered to group by an optionset. The test fails.
[Fact]publicvoidFetchXml_Aggregate_GroupByOptionset_Count(){varfetchXml=@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'> <entity name='contact'> <attribute name='contactid' alias='count.contacts' aggregate='count' /> <attribute name='gendercode' alias='group.gendercode' groupby='true' /> </entity> </fetch>";varmale=new OptionSetValue(1);varfemale=new OptionSetValue(2);varctx=new XrmFakedContext();
ctx.Initialize(new[]{new Contact(){Id= Guid.NewGuid(),GenderCode=male,FirstName="John"},new Contact(){Id= Guid.NewGuid(),GenderCode=female,FirstName="Jane"},new Contact(){Id= Guid.NewGuid(),GenderCode=male,FirstName="Sam"},new Contact(){Id= Guid.NewGuid(),GenderCode=male,FirstName="John"},});varcollection= ctx.GetFakedOrganizationService().RetrieveMultiple(new FetchExpression(fetchXml));// Make sure we only have the expected propertiesforeach(var e in collection.Entities){
Assert.Equal(new[]{"count.contacts","group.gendercode"}, e.Attributes.Keys.OrderBy(x => x));}
Assert.Equal(2, collection.Entities.Count);varmaleGroup= collection.Entities.SingleOrDefault(x =>(male.Value).Equals(x.GetAttributeValue<AliasedValue>("group.gendercode").Value));
Assert.Equal(3, maleGroup.GetAttributeValue<AliasedValue>("count.contacts").Value);varfemaleGroup= collection.Entities.SingleOrDefault(x =>(female.Value).Equals(x.GetAttributeValue<AliasedValue>("group.gendercode").Value));
Assert.Equal(1, femaleGroup.GetAttributeValue<AliasedValue>("count.contacts").Value);}
When a FetchXml aggregate includes a groupby clause on an optionset value then FakeXrmEasy will return incorrect results. The following unit tests is similar to other tests within AggregateTests.cs, except it is altered to group by an optionset. The test fails.
Output of unit test:
The text was updated successfully, but these errors were encountered: