Summary

Class:FakeXrmEasy.FakeMessageExecutors.SetStateRequestExecutor
Assembly:FakeXrmEasy
File(s):F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\SetStateRequestExecutor.cs
Covered lines:17
Uncovered lines:0
Coverable lines:17
Total lines:38
Line coverage:100%

Metrics

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

File(s)

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

#LineLine coverage
 1using Microsoft.Crm.Sdk.Messages;
 2using Microsoft.Xrm.Sdk;
 3using System;
 4
 5namespace FakeXrmEasy.FakeMessageExecutors
 6{
 7    public class SetStateRequestExecutor : IFakeMessageExecutor
 8    {
 9        public bool CanExecute(OrganizationRequest request)
 1210        {
 1211            return request is SetStateRequest;
 1212        }
 13
 14        public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
 1215        {
 1216            var req = request as SetStateRequest;
 17
 18            //We are going to translate a SetStateRequest into an update message basically
 19
 1220            var entityName = req.EntityMoniker.LogicalName;
 1221            var guid = req.EntityMoniker.Id;
 22
 1223            var entityToUpdate = new Entity(entityName) { Id = guid };
 1224            entityToUpdate["statecode"] = req.State;
 1225            entityToUpdate["statuscode"] = req.Status;
 26
 1227            var fakedService = ctx.GetFakedOrganizationService();
 1228            fakedService.Update(entityToUpdate);
 29
 1230            return new SetStateResponse();
 1231        }
 32
 33        public Type GetResponsibleRequestType()
 426434        {
 426435            return typeof(SetStateRequest);
 426436        }
 37    }
 38}