Summary

Class:FakeXrmEasy.FakeMessageExecutors.RetrieveAttributeRequestExecutor
Assembly:FakeXrmEasy
File(s):C:\code\jordimontana82\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\RetrieveAttributeRequestExecutor.cs
Covered lines:33
Uncovered lines:2
Coverable lines:35
Total lines:64
Line coverage:94.2%
Branch coverage:90%

Metrics

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

File(s)

C:\code\jordimontana82\fake-xrm-easy\FakeXrmEasy.Shared\FakeMessageExecutors\RetrieveAttributeRequestExecutor.cs

#LineLine coverage
 1using Microsoft.Xrm.Sdk;
 2using Microsoft.Xrm.Sdk.Messages;
 3using System;
 4using System.Linq;
 5
 6namespace FakeXrmEasy.FakeMessageExecutors
 7{
 8    public class RetrieveAttributeRequestExecutor : IFakeMessageExecutor
 9    {
 10        public bool CanExecute(OrganizationRequest request)
 5411        {
 5412            return request is RetrieveAttributeRequest;
 5413        }
 14
 15        public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx)
 5416        {
 5417            var req = request as RetrieveAttributeRequest;
 18
 5419             if (string.IsNullOrWhiteSpace(req.EntityLogicalName))
 620            {
 621                throw new Exception("The EntityLogicalName property must be provided in this request");
 22            }
 23
 4824             if (string.IsNullOrWhiteSpace(req.LogicalName))
 625            {
 626                throw new Exception("The LogicalName property must be provided in this request");
 27            }
 28
 4229            var entityMetadata = ctx.GetEntityMetadataByName(req.EntityLogicalName);
 4230             if(entityMetadata == null)
 631            {
 632                throw new Exception(string.Format("The entity metadata with logical name {0} wasn't initialized. Please 
 33            }
 34
 3635             if(entityMetadata.Attributes == null)
 636            {
 637                throw new Exception(string.Format("The attribute {0} wasn't found in entity metadata with logical name {
 38            }
 39
 3040            var attributeMetadata = entityMetadata.Attributes
 6041                                    .FirstOrDefault(a => a.LogicalName.Equals(req.LogicalName));
 42
 3043             if (attributeMetadata == null)
 044            {
 045                throw new Exception(string.Format("The attribute {0} wasn't found in entity metadata with logical name {
 46            }
 47
 3048            var response = new RetrieveAttributeResponse()
 3049            {
 3050                Results = new ParameterCollection
 3051                {
 3052                    { "AttributeMetadata", attributeMetadata }
 3053                }
 3054            };
 55
 3056            return response;
 3057        }
 58
 59        public Type GetResponsibleRequestType()
 427060        {
 427061            return typeof(RetrieveAttributeRequest);
 427062        }
 63    }
 64}