0

Currently I am trying to write tests for Dynamics CRM app using Fake XRM Easy. This code gives me an error.

          var executeMultiple = new ExecuteMultipleRequest
            {
                Settings = new ExecuteMultipleSettings
                {
                    ContinueOnError = true,
                    ReturnResponses = true
                },
                Requests = new OrganizationRequestCollection()
            };

            executeMultiple.Requests.AddRange(this.requestBag.Select(x => x.request));

            try
            {
                var batchResponse = (ExecuteMultipleResponse)this.orgService.Execute(executeMultiple);

                foreach (var response in batchResponse.Responses)
                {
                    this.requestsPerformedByServiceCounter++;
                    this.OnResponseReceived(new ResponseReceivedEventArgs
                    {
                        Fault = response.Fault,
                        RequestIndex = response.RequestIndex,
                        Response = response.Response,
                        Request = this.requestBag[response.RequestIndex].request,
                        Identifier = this.requestBag[response.RequestIndex].identifier,
                        TotalRequestsPerformed = this.requestsPerformedByServiceCounter,
                    });
                }

                this.requestBag.Clear();

This method is calling upper method

foreach (var company in this.companies)
            {
                EntityReference existedAccountRef = null;
                if (!string.IsNullOrEmpty(company.id.ToString()))
                {
                    var existedAccount = this.crmService.IsCompanyExistInCrm(company.id);
                    existedAccountRef = existedAccount != null ? existedAccount.ToEntityReference() : null;
                }

                if (existedAccountRef != null)
                {
                    bulkExecutionService.Update(new Account()
                    {
                        AccountId = existedAccountRef.Id,
                        Name = company.name,
                        odx_Bank_Account_Number = company.bank_account_number,
                        // odx_Company_share_Capital = company.company_share_capital, todo
                        odx_Is_Foreign = company.is_foreign,
                        odx_KRS = company.krs,
                        odx_Legal_form = company.legal_form,
                        odx_NIP = company.nip,
                        odx_Paynow_Created_at = company.created_at,
                        odx_Paynow_Modified_at = company.modified_at,
                        odx_PaynowID = company.id,
                        odx_pkd = company.pkd,
                        odx_regon = company.regon,
                        odx_Vat_EU = company.vat_eu
                    }, company.id);
                }
                else
                {
                    bulkExecutionService.Create(new Account()
                    {
                        Name = company.name,
                        odx_Bank_Account_Number = company.bank_account_number,
                        // odx_Company_share_Capital = company.company_share_capital, todo
                        odx_Is_Foreign = company.is_foreign,
                        odx_KRS = company.krs,
                        odx_Legal_form = company.legal_form,
                        odx_NIP = company.nip,
                        odx_Paynow_Created_at = company.created_at,
                        odx_Paynow_Modified_at = company.modified_at,
                        odx_PaynowID = company.id,
                        odx_pkd = company.pkd,
                        odx_regon = company.regon,
                        odx_Vat_EU = company.vat_eu
                    }, company.id);
                }
            }

            bulkExecutionService.FinalizeExecutor();

Error I am getting is in this line:

var batchResponse = (ExecuteMultipleResponse)this.orgService.Execute(executeMultiple);

FakeXrmEasy.Abstractions.Exceptions.PullRequestException: 'Exception: The organization request type 'Microsoft.Xrm.Sdk.Messages.ExecuteMultipleRequest' is not yet supported...

To be honest i don't know what can I do with it.

1 Answers1

0

Did you try installing FakeXrmEasy.Messages package?

FakeXrmEasy v2 or later now use a modular architecture.

Create, Retrieve, Update, Delete, Upsert, Associate or Dissasociate messages live in the FakeXrmEasy.Core package but other messages live now in that dedicated FakeXrmEasy.Messages package.

This is covered in the Installing section of the docs site

EDIT: After installing the Messages package, please also add a reference to one of the fake message executors in the middleware setup like this:

.AddFakeMessageExecutors(Assembly.GetAssembly(typeof(AddListMembersListRequestExecutor)))

This will use reflection to find any other fake messages. You can call that method as many times as you want in case you have your own messages in your own assembly. This is possible since the 2.1.x and 3.1.x versions.

Please check the release notes here:

https://dynamicsvalue.github.io/fake-xrm-easy-docs/releases/2x/2.1.1/

Jordi
  • 1,460
  • 9
  • 9