public void Issue_1056() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_1056>(instance => { instance.T1(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.Lambda.cs") .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 110, 119) .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 122, 124) .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 127, 129) .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 131, 131) .AssertLinesCovered(BuildConfiguration.Debug, (110, 1), (111, 2), (112, 2), (113, 2), (114, 2), (115, 2), (116, 2), (117, 2), (118, 2), (119, 1), (122, 2), (123, 2), (124, 2), (127, 2), (128, 2), (129, 2), (131, 4)); } finally { File.Delete(path); } }
public void If_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.If(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 19, 20, 22, 23, 24, 25, 29, 30) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 26, 27); } finally { File.Delete(path); } }
public void Switch_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.Switch(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 33, 34, 36, 39, 40, 44, 45, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 64, 65, 68, 69) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 41, 42); } finally { File.Delete(path); } }
public void WithLeave_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.WithLeave(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 147, 149, 150, 151, 152, 153, 154, 155, 156, 159, 161, 166, 167, 168) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 163, 164); } finally { File.Delete(path); } }
public void FiltersAndFinallies_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.FiltersAndFinallies(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 171, 173, 174, 175, 179, 180, 181, 182, 185, 186, 187, 188, 192, 193, 194) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 176, 177, 183, 184, 189, 190, 195, 196, 197); } finally { File.Delete(path); } }
public void SelectionStatements_Switch() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <SelectionStatements>(instance => { instance.Switch(1); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.SelectionStatements.cs") .AssertLinesCovered(BuildConfiguration.Release, (24, 1), (26, 0), (28, 0)) .AssertBranchesCovered(BuildConfiguration.Release, (24, 1, 1)) .AssertLinesCovered(BuildConfiguration.Debug, (20, 1), (21, 1), (24, 1), (30, 1)) .AssertBranchesCovered(BuildConfiguration.Debug, (21, 0, 0), (21, 1, 1), (21, 2, 0), (21, 3, 0)); } finally { File.Delete(path); } }
public void Subtle_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.Subtle(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 72, 73, 75, 78, 82, 83, 86, 87, 91, 92, 95, 101, 102, 103) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 79, 80, 88, 96, 98, 99); } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverageAutoGeneratedGet() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <AutoGeneneratedGetOnly>(instance => { instance.SetId(10); Assert.Equal(10, instance.Id); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFromCoverage.cs") .AssertNonInstrumentedLines(BuildConfiguration.Debug, 177) .AssertLinesCovered(BuildConfiguration.Debug, 178, 181); } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverage_Issue1302() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue1302>(instance => { instance.Run(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFromCoverage.Issue1302.cs") .AssertNonInstrumentedLines(BuildConfiguration.Debug, 10, 13); } finally { File.Delete(path); } }
public void Lambda_Issue343() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Lambda_Issue343>(instance => { instance.InvokeAnonymous_Test(); ((Task <bool>)instance.InvokeAnonymousAsync_Test()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.Lambda.cs") .AssertLinesCoveredAllBut(BuildConfiguration.Debug, 23, 51) .AssertBranchesCovered(BuildConfiguration.Debug, // Expected branches (22, 0, 0), (22, 1, 1), (50, 0, 0), (50, 1, 1) ); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_730() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_730>(instance => { ((Task)instance.Invoke()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize, disableRestoreModules: true); return(0); }, path, invokeInProcess: true).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.Lambda.cs") .AssertLinesCovered(BuildConfiguration.Debug, (72, 1), (73, 1), (74, 101), (75, 1), (76, 1)) .ExpectedTotalNumberOfBranches(BuildConfiguration.Debug, 0); } finally { File.Delete(path); } }
public void Yield_Two() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Yield>(instance => { foreach (dynamic _ in instance.Two()) { ; } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.Yield.cs") .Method("System.Boolean Coverlet.Core.Samples.Tests.Yield/<Two>d__1::MoveNext()") .AssertLinesCovered((14, 1), (15, 1)) .ExpectedTotalNumberOfBranches(0); } finally { File.Delete(path); } }
public void Lambda_Issue760() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_760>(instance => { ((Task)instance.If()).ConfigureAwait(false).GetAwaiter().GetResult(); ((Task)instance.Foreach()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.Lambda.cs") .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 83, 92) .AssertLinesCoveredFromTo(BuildConfiguration.Debug, 95, 104); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_730() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_730>(instance => { ((Task)instance.Invoke()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.Lambda.cs") .AssertLinesCovered(BuildConfiguration.Debug, (73, 1), (74, 1), (75, 101), (76, 1), (77, 1)) .ExpectedTotalNumberOfBranches(BuildConfiguration.Debug, 0); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_1177() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_1177>(instance => { ((Task)instance.Test()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); Core.Instrumentation.Document document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs"); document.AssertLinesCovered(BuildConfiguration.Debug, (133, 1), (134, 1), (135, 1), (136, 1), (137, 1)); Assert.DoesNotContain(document.Branches, x => x.Key.Line == 134); } finally { File.Delete(path); } }
public void CallsGenericClassDoesNotReturn_DoesNotReturnAttribute_InstrumentsCorrect() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <DoesNotReturn>(instance => { try { instance.CallsGenericClassDoesNotReturn(); } catch (Exception) { } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0], doesNotReturnAttributes: _ => new string[] { "DoesNotReturnAttribute" }); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.DoesNotReturn.cs") .AssertInstrumentLines(BuildConfiguration.Debug, 134, 135, 140, 141, 142) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 143, 144); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_1275() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_1275>(instance => { var cts = new CancellationTokenSource(); ((Task)instance.Execute(cts.Token)).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); Core.Instrumentation.Document document = TestInstrumentationHelper.GetCoverageResult(path).Document("Instrumentation.AsyncAwait.cs"); document.AssertLinesCoveredFromTo(BuildConfiguration.Debug, 170, 176); document.AssertBranchesCovered(BuildConfiguration.Debug, (171, 0, 1), (171, 1, 1)); Assert.DoesNotContain(document.Branches, x => x.Key.Line == 176); } finally { File.Delete(path); } }
public void ExcludeFilteredNestedTypes() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <ExcludeFilterClass1>(instance => { Assert.Equal(42, instance.Run()); return(Task.CompletedTask); }, excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterClass2" }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFilter.cs") .AssertLinesCovered(BuildConfiguration.Debug, (73, 1)) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 75, 93); } finally { File.Delete(path); } }
public void Yield_SingleWithSwitch() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Yield>(instance => { foreach (var _ in instance.OneWithSwitch(2)) { ; } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.Yield.cs") .Method("System.Boolean Coverlet.Core.Samples.Tests.Yield/<OneWithSwitch>d__2::MoveNext()") .AssertLinesCovered(BuildConfiguration.Debug, (21, 1), (30, 1), (31, 1), (37, 1)) .ExpectedTotalNumberOfBranches(1); } finally { File.Delete(path); } }
public void Yield_Enumerable() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Yield>(instance => { foreach (var _ in instance.Enumerable(new[] { "one", "two", "three", "four" })) { ; } return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.Yield.cs") .Method("System.Boolean Coverlet.Core.Samples.Tests.Yield/<Enumerable>d__4::MoveNext()") .AssertLinesCovered(BuildConfiguration.Debug, (48, 1), (49, 1), (50, 4), (51, 5), (52, 1), (54, 4), (55, 4), (56, 4), (57, 1)) .ExpectedTotalNumberOfBranches(1); } finally { File.Delete(path); } }
public void SelectionStatements_Switch_CSharp8_OneBranch() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <SelectionStatements>(instance => { instance.SwitchCsharp8(int.MaxValue); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.SelectionStatements.cs") .AssertLinesCovered(BuildConfiguration.Debug, 33, 34, 35, 36, 40) .AssertLinesNotCovered(BuildConfiguration.Debug, 37, 38, 39) .AssertBranchesCovered(BuildConfiguration.Debug, (34, 0, 1), (34, 1, 0), (34, 2, 0), (34, 3, 0), (34, 4, 0), (34, 5, 0)) .ExpectedTotalNumberOfBranches(3); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_669_2() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_669_2>(instance => { ((ValueTask <System.Net.Http.HttpResponseMessage>)instance.SendRequest()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.AsyncAwait.cs") .AssertLinesCovered(BuildConfiguration.Debug, (7, 1), (10, 1), (11, 1), (12, 1), (13, 1), (15, 1)) .ExpectedTotalNumberOfBranches(BuildConfiguration.Debug, 0); } finally { File.Delete(path); } }
public void AsyncAwait_Issue_669_1() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <Issue_669_1>(instance => { ((Task)instance.Test()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.AsyncAwait.cs") .AssertLinesCovered(BuildConfiguration.Debug, (97, 1), (98, 1), (99, 1), (101, 1), (102, 1), (103, 1), (110, 1), (111, 1), (112, 1), (113, 1), (116, 1), (117, 1), (118, 1), (119, 1)); } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverageNextedTypes() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <ExcludeFromCoverageAttrFilterClass1>(instance => { Assert.Equal(42, instance.Run()); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFromCoverage.cs") .AssertLinesCovered(BuildConfiguration.Debug, (143, 1)) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 146, 160); } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverage_Issue809() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <TaskRepo_Issue809>(instance => { Assert.True(((Task <bool>)instance.EditTask(null, 10)).GetAwaiter().GetResult()); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFromCoverage.Issue809.cs") // public async Task<bool> EditTask(Tasks_Issue809 tasks, int val) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 153, 162) // .AssertNonInstrumentedLines(BuildConfiguration.Debug, 167, 170) -> Shoud be not covered, issue with lambda .AssertNonInstrumentedLines(BuildConfiguration.Debug, 167, 197) // public List<Tasks_Issue809> GetAllTasks() // .AssertNonInstrumentedLines(BuildConfiguration.Debug, 263, 266) -> Shoud be not covered, issue with lambda .AssertNonInstrumentedLines(BuildConfiguration.Debug, 263, 264); // .AssertNonInstrumentedLines(BuildConfiguration.Debug, 269, 275) -> Shoud be not covered, issue with lambda } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverageCompilerGeneratedMethodsAndTypes_Issue670() { string path = Path.GetTempFileName(); try { FunctionExecutor.Run(async(string[] pathSerialize) => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <MethodsWithExcludeFromCodeCoverageAttr_Issue670>(instance => { instance.Test("test"); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize[0]); return(0); }, new string[] { path }); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.ExcludeFromCoverage.Issue670.cs") .AssertLinesCovered(BuildConfiguration.Debug, (8, 1), (9, 1), (10, 1), (11, 1)) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 15, 53); } finally { File.Delete(path); } }
public void ExcludeFilteredTypes() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <ExcludeFilterOuterTypes>(instance => { Assert.Equal(42, instance.Run()); return(Task.CompletedTask); }, excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterOuterTypes" }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFilter.cs") .AssertNonInstrumentedLines(BuildConfiguration.Debug, 1, 62) .AssertLinesCovered(BuildConfiguration.Debug, (66, 1), (68, 1)); } finally { File.Delete(path); } }
public void ExcludeFromCodeCoverage_CompilerGeneratedMethodsAndTypes_NestedMembers() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <MethodsWithExcludeFromCodeCoverageAttr_NestedStateMachines>(instance => { instance.Test(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.ExcludeFromCoverage.NestedStateMachines.cs") .AssertLinesCovered(BuildConfiguration.Debug, (14, 1), (15, 1), (16, 1)) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 9, 11); } finally { File.Delete(path); } }
public void AsyncAwait() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <AsyncAwait>(instance => { instance.SyncExecution(); int res = ((Task <int>)instance.AsyncExecution(true)).ConfigureAwait(false).GetAwaiter().GetResult(); res = ((Task <int>)instance.AsyncExecution(1)).ConfigureAwait(false).GetAwaiter().GetResult(); res = ((Task <int>)instance.AsyncExecution(2)).ConfigureAwait(false).GetAwaiter().GetResult(); res = ((Task <int>)instance.AsyncExecution(3)).ConfigureAwait(false).GetAwaiter().GetResult(); res = ((Task <int>)instance.ContinuationCalled()).ConfigureAwait(false).GetAwaiter().GetResult(); res = ((Task <int>)instance.ConfigureAwait()).ConfigureAwait(false).GetAwaiter().GetResult(); return(Task.CompletedTask); }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path); result.Document("Instrumentation.AsyncAwait.cs") .AssertLinesCovered(BuildConfiguration.Debug, // AsyncExecution(bool) (10, 1), (11, 1), (12, 1), (14, 1), (16, 1), (17, 0), (18, 0), (19, 0), (21, 1), (22, 1), // Async (25, 9), (26, 9), (27, 9), (28, 9), // SyncExecution (31, 1), (32, 1), (33, 1), // Sync (36, 1), (37, 1), (38, 1), // AsyncExecution(int) (41, 3), (42, 3), (43, 3), (46, 1), (47, 1), (48, 1), (51, 1), (52, 1), (53, 1), (56, 1), (57, 1), (58, 1), (59, 1), (62, 0), (63, 0), (64, 0), (65, 0), (68, 0), (70, 3), (71, 3), // ContinuationNotCalled (74, 0), (75, 0), (76, 0), (77, 0), (78, 0), // ContinuationCalled -> line 83 should be 1 hit some issue with Continuation state machine (81, 1), (82, 1), (83, 2), (84, 1), (85, 1), // ConfigureAwait (89, 1), (90, 1) ) .AssertBranchesCovered(BuildConfiguration.Debug, (16, 0, 0), (16, 1, 1), (43, 0, 3), (43, 1, 1), (43, 2, 1), (43, 3, 1), (43, 4, 0)) // Real branch should be 2, we should try to remove compiler generated branch in method ContinuationNotCalled/ContinuationCalled // for Continuation state machine .ExpectedTotalNumberOfBranches(BuildConfiguration.Debug, 4); } finally { File.Delete(path); } }
public void ExcludeFilteredNestedAutogeneratedTypes() { string path = Path.GetTempFileName(); try { RemoteExecutor.Invoke(async pathSerialize => { CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run <ExcludeFilterNestedAutogeneratedTypes>(instance => { instance.Run(); PropertyInfo stateProp = null; foreach (Type type in ((Type)instance.GetType()).Assembly.GetTypes()) { if (typeof(Issue_689).FullName == type.FullName) { Assert.Equal(0, (stateProp = type.GetProperty("State")).GetValue(null)); break; } } foreach (Type type in ((Type)instance.GetType()).Assembly.GetTypes()) { if (typeof(EventSource_Issue_689).FullName == type.FullName) { type.GetMethod("RaiseEvent").Invoke(null, null); break; } } Assert.Equal(2, stateProp.GetValue(null)); return(Task.CompletedTask); }, includeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*ExcludeFilterNestedAutogeneratedTypes", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Issue_689" }, excludeFilter: moduleFileName => new string[] { $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*NestedToFilterOut", $"[{Path.GetFileNameWithoutExtension(moduleFileName)}*]*Uncoverlet" }, persistPrepareResultToFile: pathSerialize); return(0); }, path).Dispose(); TestInstrumentationHelper.GetCoverageResult(path) .Document("Instrumentation.ExcludeFilter.cs") .AssertLinesCovered(BuildConfiguration.Debug, (12, 1), (13, 1), (14, 1)) .AssertLinesCovered(BuildConfiguration.Debug, (27, 1), (28, 1), (29, 1), (30, 1), (31, 1)) .AssertLinesCovered(BuildConfiguration.Debug, (39, 2), (40, 2), (41, 2), (43, 5)) .AssertLinesCovered(BuildConfiguration.Debug, (50, 1), (51, 1), (52, 1)) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 17, 21) .AssertNonInstrumentedLines(BuildConfiguration.Debug, 33, 36); } finally { File.Delete(path); } }