Summary

Class:FakeXrmEasy.FakeMessageExecutors.AssignRequestExecutor
Assembly:FakeXrmEasy
File(s):F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\AssignRequestExecutor.cs
Covered lines:35
Uncovered lines:0
Coverable lines:35
Total lines:62
Line coverage:100%
Branch coverage:87.5%

Metrics

MethodCyclomatic ComplexitySequence CoverageBranch Coverage
CanExecute(...)1100100
Execute(...)510088.89
GetResponsibleRequestType()1100100

File(s)

F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\AssignRequestExecutor.cs

#LineLine coverage
 1using Microsoft.Crm.Sdk.Messages;
 2using Microsoft.Xrm.Sdk;
 3using System;
 4using System.Collections.Generic;
 5using System.ServiceModel;
 6
 7namespace FakeXrmEasy.FakeMessageExecutors
 8{
 9    public class AssignRequestExecutor : IFakeMessageExecutor
 10    {
 11        public bool CanExecute(OrganizationRequest request)
 1212        {
 1213            return request is AssignRequest;
 1214        }
 15
 16        public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
 3017        {
 3018            var assignRequest = (AssignRequest)request;
 19
 3020            var target = assignRequest.Target;
 3021            var assignee = assignRequest.Assignee;
 22
 3023             if (target == null)
 624            {
 625                throw new FaultException<OrganizationServiceFault>(new OrganizationServiceFault(), "Can not assign witho
 26            }
 27
 2428             if (assignee == null)
 629            {
 630                throw new FaultException<OrganizationServiceFault>(new OrganizationServiceFault(), "Can not assign witho
 31            }
 32
 1833            var service = ctx.GetOrganizationService();
 34
 1835            KeyValuePair<string, object> owningX = new KeyValuePair<string, object>();
 1836             if (assignee.LogicalName == "systemuser")
 1237                owningX = new KeyValuePair<string, object>("owninguser", assignee);
 638             else if (assignee.LogicalName == "team")
 639                owningX = new KeyValuePair<string, object>("owningteam", assignee);
 40
 1841            var assignment = new Entity
 1842            {
 1843                LogicalName = target.LogicalName,
 1844                Id = target.Id,
 1845                Attributes = new AttributeCollection
 1846                {
 1847                    { "ownerid", assignee },
 1848                    owningX
 1849                }
 1850            };
 51
 1852            service.Update(assignment);
 53
 1854            return new AssignResponse();
 1855        }
 56
 57        public Type GetResponsibleRequestType()
 426458        {
 426459            return typeof(AssignRequest);
 426460        }
 61    }
 62}