public void Equals() { var target1 = new Branch(10, "Test"); var target2 = new Branch(11, "Test"); var target3 = new Branch(10, "Test123"); Assert.IsTrue(target1.Equals(target2), "Objects are not equal"); Assert.IsFalse(target1.Equals(target3), "Objects are equal"); Assert.IsFalse(target1.Equals(null), "Objects are equal"); Assert.IsFalse(target1.Equals(new object()), "Objects are equal"); }
/// <summary> /// Gets the branches by line number. /// </summary> /// <param name="methods">The methods.</param> /// <param name="fileIds">The file ids of the class.</param> /// <returns>The branches by line number.</returns> private static Dictionary<int, List<Branch>> GetBranches(XElement[] methods, HashSet<string> fileIds) { var result = new Dictionary<int, List<Branch>>(); var branchPoints = methods .Elements("BranchPoints") .Elements("BranchPoint") .ToArray(); // OpenCover supports this since version 4.5.3207 if (branchPoints.Length == 0 || branchPoints[0].Attribute("sl") == null) { return result; } foreach (var branchPoint in branchPoints) { if (branchPoint.Attribute("fileid") != null && !fileIds.Contains(branchPoint.Attribute("fileid").Value)) { // If fileid is available, verify that branch belongs to same file (available since version OpenCover.4.5.3418) continue; } int lineNumber = int.Parse(branchPoint.Attribute("sl").Value, CultureInfo.InvariantCulture); string identifier = string.Format( CultureInfo.InvariantCulture, "{0}_{1}_{2}_{3}", lineNumber, branchPoint.Attribute("path").Value, branchPoint.Attribute("offset").Value, branchPoint.Attribute("offsetend").Value); var branch = new Branch( int.Parse(branchPoint.Attribute("vc").Value, CultureInfo.InvariantCulture), identifier); List<Branch> branches = null; if (result.TryGetValue(lineNumber, out branches)) { branches.Add(branch); } else { branches = new List<Branch>(); branches.Add(branch); result.Add(lineNumber, branches); } } return result; }
public void Constructor() { var sut = new Branch(10, "Test"); Assert.AreEqual(10, sut.BranchVisits, "Not equal"); }