public void GetBranchPointsForMethodToken_OneBranch() { // arrange _mockFilter .Setup(x => x.InstrumentClass(It.IsAny <string>(), It.IsAny <string>())) .Returns(true); var types = _reader.GetInstrumentableTypes(); var type = types.First(x => x.FullName == typeof(DeclaredConstructorClass).FullName); var methods = _reader.GetMethodsForType(type, new File[0]); // act var points = _reader.GetBranchPointsForToken(methods.First(x => x.Name.Contains("::HasSingleDecision")).MetadataToken); // assert Assert.IsNotNull(points); Assert.AreEqual(2, points.Count()); Assert.AreEqual(points[0].Offset, points[1].Offset); Assert.AreEqual(0, points[0].Path); Assert.AreEqual(1, points[1].Path); Assert.AreEqual(19, points[0].StartLine); Assert.AreEqual(19, points[1].StartLine); Assert.NotNull(points[1].Document); Assert.AreEqual(points[0].Document, points[1].Document); }
public void Issue960IgnoresEmptyBranchesGeneratedForSwitchExpressions_UnoptimisedCode() { // arrange _mockFilter .Setup(x => x.InstrumentClass(It.IsAny <string>(), It.IsAny <string>())) .Returns(true); var types = _reader.GetInstrumentableTypes(); var type = types.First(x => x.FullName.EndsWith("SwitchExpression")); var methods = _reader.GetMethodsForType(type, new File[0]); var points = _reader.GetBranchPointsForToken(methods.First(x => x.FullName.Contains("::MapMyTest")).MetadataToken); Assert.AreEqual(4, points.Count()); Assert.AreEqual(6, points.First().Offset); }