Summary

Class:FakeXrmEasy.FakeMessageExecutors.CloseQuoteRequestExecutor
Assembly:FakeXrmEasy
File(s):F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\CloseQuoteRequestExecutor.cs
Covered lines:26
Uncovered lines:6
Coverable lines:32
Total lines:59
Line coverage:81.2%
Branch coverage:50%

Metrics

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

File(s)

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

#LineLine coverage
 1using Microsoft.Crm.Sdk.Messages;
 2using Microsoft.Xrm.Sdk;
 3using System;
 4
 5namespace FakeXrmEasy.FakeMessageExecutors
 6{
 7    public class CloseQuoteRequestExecutor : IFakeMessageExecutor
 8    {
 9        public bool CanExecute(OrganizationRequest request)
 610        {
 611            return request is CloseQuoteRequest;
 612        }
 13
 14        public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
 615        {
 616            var closeRequest = request as CloseQuoteRequest;
 17
 618             if (closeRequest == null)
 019            {
 020                throw new Exception("You did not pass a CloseQuoteRequest");
 21            }
 22
 623            var quoteClose = closeRequest.QuoteClose;
 24
 625             if (quoteClose == null)
 026            {
 027                throw new Exception("QuoteClose is mandatory");
 28            }
 29
 630            var quoteId = quoteClose.GetAttributeValue<EntityReference>("quoteid");
 31
 632             if (quoteId == null)
 033            {
 034                throw new Exception("Quote ID is not set on QuoteClose, but is required");
 35            }
 36
 637            var update = new Entity
 638            {
 639                Id = quoteId.Id,
 640                LogicalName = "quote",
 641                Attributes = new AttributeCollection
 642                {
 643                    { "statuscode", closeRequest.Status }
 644                }
 645            };
 46
 647            var service = ctx.GetOrganizationService();
 48
 649            service.Update(update);
 50
 651            return new CloseQuoteResponse();
 652        }
 53
 54        public Type GetResponsibleRequestType()
 426455        {
 426456            return typeof(CloseQuoteRequest);
 426457        }
 58    }
 59}