public void FindMethod_SearchNonExistingGenericMethod_PositionIsNull()
        {
            PartCoverMethodElement partCoverMethodElement = new PartCoverMethodElement(
                "TestNamespace.AnalyzerTestClass",
                "GenericMethod",
                "void  (int)");

            var methodPosition = SourceCodeAnalyzer.FindSourceElement(elementClassFile, partCoverMethodElement);

            Assert.IsNull(methodPosition, "MethodPosition is not null.");
        }
        public void FindMethod_SearchExistingMethod_PositionMustNotBeNullAndSupplyCorrectLinenumber()
        {
            PartCoverMethodElement partCoverMethodElement = new PartCoverMethodElement(
                "TestNamespace.AnalyzerTestClass",
                "DoSomething",
                "string  (string, string[], System.Guid, string, string, System.Decimal, int, long, stringint, ref int, float, double, bool, unsigned byte, char, object, byte, short, unsigned int, unsigned long, unsigned short, ICSharpCode.NRefactory.Ast.INode)");

            var methodPosition = SourceCodeAnalyzer.FindSourceElement(elementClassFile, partCoverMethodElement);

            Assert.IsNotNull(methodPosition, "MethodPosition must not be null.");

            Assert.AreEqual(37, methodPosition.Start, "Start line number does not match.");
            Assert.AreEqual(40, methodPosition.End, "End line number does not match.");
        }
        public void FindMethod_SearchExistingConstructor_PositionMustNotBeNullAndSupplyCorrectLinenumber()
        {
            PartCoverMethodElement partCoverMethodElement = new PartCoverMethodElement(
                "TestNamespace.AnalyzerTestClass",
                ".ctor",
                "void  ()");

            var methodPosition = SourceCodeAnalyzer.FindSourceElement(elementClassFile, partCoverMethodElement);

            Assert.IsNotNull(methodPosition, "MethodPosition must not be null.");

            Assert.AreEqual(10, methodPosition.Start, "Start line number does not match.");
            Assert.AreEqual(12, methodPosition.End, "End line number does not match.");
        }
        /// <summary>
        /// Adds the coverage data of unexecuted methods.
        /// </summary>
        /// <param name="filenameByFileIdDictionary">Dictionary containing all files used in the report by their corresponding id.</param>
        private void AddCoverageDataOfUnexecutedMethods(Dictionary<string, string> filenameByFileIdDictionary)
        {
            var unexecutedMethods = this.Report.Descendants("Type")
                .Where(type => !type.Attribute("name").Value.Contains("__"))
                .Elements("Method")
                .Where(m => !m.Attribute("name").Value.StartsWith("get_", StringComparison.Ordinal) && !m.Attribute("name").Value.StartsWith("set_", StringComparison.Ordinal))
                .Where(m => !m.Elements().Any())
                .ToArray();

            long counter = 0;
            foreach (var method in unexecutedMethods)
            {
                PartCoverMethodElement partCoverMethodElement = new PartCoverMethodElement(
                    method.Parent.Attribute("name").Value,
                    method.Attribute("name").Value,
                    method.Attribute("sig").Value);

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

                if (this.SearchElement(
                    partCoverMethodElement,
                    filenameByFileIdDictionary,
                    fileIds,
                    method,
                    UpdateMethodElement,
                    this.Report))
                {
                    counter++;
                }
            }

            if (unexecutedMethods.LongLength > 0)
            {
                Logger.DebugFormat("  " + Resources.AddedCoverageInformationUnexecutedMethods, counter, unexecutedMethods.LongLength);
            }
        }