public void FindProperty_SearchExistingProperty_PositionMustNotBeNullAndSupplyCorrectLinenumber()
        {
            PropertyElement propertyElement = new PropertyElement("TestNamespace.AnalyzerTestClass", "get_AutoProperty");

            var propertyPosition = SourceCodeAnalyzer.FindSourceElement(elementClassFile, propertyElement);

            Assert.IsNotNull(propertyPosition, "PropertyPosition must not be null.");

            Assert.AreEqual(46, propertyPosition.Start, "Start line number does not match.");
            Assert.AreEqual(46, propertyPosition.End, "End line number does not match.");
        }
        /// <summary>
        /// Adds the coverage data of auto properties.
        /// </summary>
        /// <param name="filenameByFileIdDictionary">Dictionary containing all files used in the report by their corresponding id.</param>
        private void AddCoverageDataOfAutoProperties(Dictionary<string, string> filenameByFileIdDictionary)
        {
            Func<string, bool> isProperty = v => v.StartsWith("get_", StringComparison.Ordinal) || v.StartsWith("set_", StringComparison.Ordinal);

            var unexecutedProperties = this.Report.Descendants("Type")
                .Where(type => !type.Attribute("name").Value.Contains("__"))
                .Elements("Method")
                .Where(m => isProperty(m.Attribute("name").Value)
                    && (!m.Elements().Any() || !m.Elements().Any(pt => pt.Attribute("sl") != null)))
                .ToArray();

            long counter = 0;
            foreach (var property in unexecutedProperties)
            {
                var propertyElement = new PropertyElement(property.Parent.Attribute("name").Value, property.Attribute("name").Value);

                // Get files in which property could be defined
                var fileIds = property.Parent.Descendants("pt")
                    .Where(p => p.Attribute("fid") != null)
                    .Select(p => p.Attribute("fid").Value)
                    .Distinct()
                    .ToArray();

                if (this.SearchElement(
                    propertyElement,
                    filenameByFileIdDictionary,
                    fileIds,
                    property,
                    UpdatePropertyElement,
                    this.Report))
                {
                    counter++;
                }
            }

            if (unexecutedProperties.LongLength > 0)
            {
                Logger.DebugFormat("  " + Resources.AddedCoverageInformationOfProperties, counter, unexecutedProperties.LongLength);
            }
        }
        /// <summary>
        /// Adds the coverage data of auto properties.
        /// </summary>
        /// <param name="module">The module.</param>
        private void AddCoverageDataOfAutoProperties(XElement module)
        {
            if (module.Element("Files") == null)
            {
                module.Add(new XElement("Files"));
            }

            var filenameByFileIdDictionary = module
                .Element("Files")
                .Elements("File")
                .ToDictionary(f => f.Attribute("uid").Value, f => f.Attribute("fullPath").Value);

            Func<XElement, bool> isProperty = v => v.HasAttributeWithValue("isGetter", "true") || v.HasAttributeWithValue("isSetter", "true");

            var unexecutedProperties = module
                                    .Elements("Classes")
                                    .Elements("Class")
                                    .Where(c => !c.Element("FullName").Value.Contains("__")
                                        && !c.Element("FullName").Value.Contains("<")
                                        && !c.Element("FullName").Value.Contains("/"))
                                    .Elements("Methods")
                                    .Elements("Method")
                                    .Where(m => m.Attribute("skippedDueTo") == null
                                        && isProperty(m)
                                        && m.Element("SequencePoints") != null
                                        && !m.Element("SequencePoints").Elements().Any())
                                    .ToArray();

            long counter = 0;
            foreach (var property in unexecutedProperties)
            {
                string propertyName = Regex.Match(property.Element("Name").Value, MethodRegex).Groups["MethodName"].Value;

                var propertyElement = new PropertyElement(property.Parent.Parent.Element("FullName").Value.Replace("/", string.Empty), propertyName);

                // Get files in which property could be defined
                var fileIds = property.Parent
                    .Elements("Method")
                    .Elements("FileRef")
                    .Select(f => f.Attribute("uid").Value)
                    .Distinct()
                    .ToArray();

                if (this.SearchElement(
                    propertyElement,
                    filenameByFileIdDictionary,
                    fileIds,
                    property,
                    UpdatePropertyElement,
                    property.Parent.Parent.Parent.Parent.Element("Files")))
                {
                    counter++;
                }
            }

            if (unexecutedProperties.LongLength > 0)
            {
                Logger.DebugFormat("  " + Resources.AddedCoverageInformationOfPropertiesOpenCover, counter, unexecutedProperties.LongLength, module.Element("ModuleName").Value);
            }
        }
        public void FindProperty_SearchNonExistingProperty_PositionIsNull()
        {
            PropertyElement propertyElement = new PropertyElement("TestNamespace.AnalyzerTestClass", "get_DoesNotExist");

            var propertyPosition = SourceCodeAnalyzer.FindSourceElement(elementClassFile, propertyElement);

            Assert.IsNull(propertyPosition, "PropertyPosition is not null.");
        }