0

目前我正在尝试使用 Fake XRM Easy 为 Dynamics CRM 应用程序编写测试。这段代码给了我一个错误。

          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();

该方法正在调用上层方法

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();

我得到的错误在这一行:

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

FakeXrmEasy.Abstractions.Exceptions.PullRequestException: '异常:尚不支持组织请求类型'Microsoft.Xrm.Sdk.Messages.ExecuteMultipleRequest'...

老实说,我不知道我能用它做什么。

4

1 回答 1

0

您是否尝试安装 FakeXrmEasy.Messages 包?

FakeXrmEasy v2 或更高版本现在使用模块化架构。

创建、检索、更新、删除、Upsert、关联或解除关联消息存在于 FakeXrmEasy.Core 包中,但其他消息现在存在于该专用 FakeXrmEasy.Messages 包中。

在文档站点的安装部分中有介绍

于 2022-01-27T21:41:57.500 回答