Summary

Class:FakeXrmEasy.Extensions.EntityMetadataExtensions
Assembly:FakeXrmEasy
File(s):C:\code\jordimontana82\fake-xrm-easy\FakeXrmEasy.Shared\Extensions\EntityMetadataExtensions.cs
Covered lines:29
Uncovered lines:0
Coverable lines:29
Total lines:57
Line coverage:100%
Branch coverage:100%

Metrics

MethodCyclomatic ComplexitySequence CoverageBranch Coverage
SetAttributeCollection(...)1100100
SetAttribute(...)2100100
SetAttributeCollection(...)1100100
SetSealedPropertyValue(...)1100100
SetSealedPropertyValue(...)1100100
SetSealedPropertyValue(...)1100100
SetSealedPropertyValue(...)1100100

File(s)

C:\code\jordimontana82\fake-xrm-easy\FakeXrmEasy.Shared\Extensions\EntityMetadataExtensions.cs

#LineLine coverage
 1using Microsoft.Xrm.Sdk.Metadata;
 2using System;
 3using System.Collections.Generic;
 4using System.Text;
 5using System.Linq;
 6
 7namespace FakeXrmEasy.Extensions
 8{
 9    public static class EntityMetadataExtensions
 10    {
 11        public static void SetAttributeCollection(this EntityMetadata entityMetadata, AttributeMetadata[] attributes)
 2412        {
 13            //AttributeMetadata is internal set in a sealed class so... just doing this
 14
 2415            entityMetadata.GetType().GetProperty("Attributes").SetValue(entityMetadata, attributes, null);
 2416        }
 17
 18        public static void SetAttribute(this EntityMetadata entityMetadata, AttributeMetadata attribute)
 3819        {
 3820            var currentAttributes = entityMetadata.Attributes;
 3821             if (currentAttributes == null)
 1422            {
 1423                currentAttributes = new AttributeMetadata[0];
 1424            }
 6225            var newAttributesList = currentAttributes.Where(a => a.LogicalName != attribute.LogicalName).ToList();
 3826            newAttributesList.Add(attribute);
 3827            var newAttributesArray = newAttributesList.ToArray();
 28
 3829            entityMetadata.GetType().GetProperty("Attributes").SetValue(entityMetadata, newAttributesArray, null);
 3830        }
 31
 32        public static void SetAttributeCollection(this EntityMetadata entityMetadata, IEnumerable<AttributeMetadata> att
 3633        {
 3634            entityMetadata.GetType().GetProperty("Attributes").SetValue(entityMetadata, attributes.ToList().ToArray(), n
 3635        }
 36
 37        public static void SetSealedPropertyValue(this EntityMetadata entityMetadata, string sPropertyName, object value
 849738        {
 849739            entityMetadata.GetType().GetProperty(sPropertyName).SetValue(entityMetadata, value, null);
 849740        }
 41
 42        public static void SetSealedPropertyValue(this AttributeMetadata attributeMetadata, string sPropertyName, object
 362543        {
 362544            attributeMetadata.GetType().GetProperty(sPropertyName).SetValue(attributeMetadata, value, null);
 362545        }
 46
 47        public static void SetSealedPropertyValue(this ManyToManyRelationshipMetadata manyToManyRelationshipMetadata, st
 648        {
 649            manyToManyRelationshipMetadata.GetType().GetProperty(sPropertyName).SetValue(manyToManyRelationshipMetadata,
 650        }
 51
 52        public static void SetSealedPropertyValue(this OneToManyRelationshipMetadata oneToManyRelationshipMetadata, stri
 653        {
 654            oneToManyRelationshipMetadata.GetType().GetProperty(sPropertyName).SetValue(oneToManyRelationshipMetadata, v
 655        }
 56    }
 57}