Summary

Class:FakeXrmEasy.FakeMessageExecutors.RetrieveOptionSetRequestExecutor
Assembly:FakeXrmEasy
File(s):F:\Git\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\RetrieveOptionSetRequestExecutor.cs
Covered lines:26
Uncovered lines:5
Coverable lines:31
Total lines:53
Line coverage:83.8%
Branch coverage:83.3%

Metrics

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

File(s)

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

#LineLine coverage
 1using Microsoft.Xrm.Sdk;
 2using Microsoft.Xrm.Sdk.Messages;
 3using System;
 4
 5namespace FakeXrmEasy.FakeMessageExecutors
 6{
 7    public class RetrieveOptionSetRequestExecutor : IFakeMessageExecutor
 8    {
 9        public bool CanExecute(OrganizationRequest request)
 610        {
 611            return request is RetrieveOptionSetRequest;
 612        }
 13
 14        public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
 1815        {
 1816            var retrieveOptionSetRequest = (RetrieveOptionSetRequest)request;
 17
 1818             if (retrieveOptionSetRequest.MetadataId != Guid.Empty) //ToDo: Implement retrieving option sets by Id
 019            {
 020                FakeOrganizationServiceFault.Throw(ErrorCodes.ObjectDoesNotExist, $"Could not find optionset with option
 021            }
 22
 1823            var name = retrieveOptionSetRequest.Name;
 24
 1825             if (string.IsNullOrEmpty(name))
 626            {
 627                FakeOrganizationServiceFault.Throw(ErrorCodes.InvalidArgument, "Name is required when optionSet id is no
 028            }
 29
 1230             if (!ctx.OptionSetValuesMetadata.ContainsKey(name))
 631            {
 632                FakeOrganizationServiceFault.Throw(ErrorCodes.ObjectDoesNotExist, string.Format("An OptionSetMetadata wi
 033            }
 34
 635            var optionSetMetadata = ctx.OptionSetValuesMetadata[name];
 36
 637            var response = new RetrieveOptionSetResponse()
 638            {
 639                Results = new ParameterCollection
 640                        {
 641                            { "OptionSetMetadata", optionSetMetadata }
 642                        }
 643            };
 44
 645            return response;
 646        }
 47
 48        public Type GetResponsibleRequestType()
 426449        {
 426450            return typeof(RetrieveOptionSetRequest);
 426451        }
 52    }
 53}