Skip to content

Commit 751b128

Browse files
committed
initial unit test
1 parent 67e37bb commit 751b128

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

test/coverlet.core.tests/Coverage/CoverageTests.AwaitUsing.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,29 @@ public void AwaitUsing()
4949
File.Delete(path);
5050
}
5151
}
52+
53+
[Fact]
54+
public void AwaitUsingGeneric()
55+
{
56+
string path = Path.GetTempFileName();
57+
try
58+
{
59+
FunctionExecutor.RunInProcess(async (string[] pathSerialize) =>
60+
{
61+
CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<AwaitUsing>(async instance =>
62+
{
63+
await (Task)instance.Issue1490_Repro<string>();
64+
65+
}, persistPrepareResultToFile: pathSerialize[0]);
66+
return 0;
67+
}, new string[] { path });
68+
69+
TestInstrumentationHelper.GetCoverageResult(path).GenerateReport(show: true);
70+
}
71+
finally
72+
{
73+
File.Delete(path);
74+
}
75+
}
5276
}
5377
}

test/coverlet.core.tests/Coverage/InstrumenterHelper.Assertions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static CoverageResult GenerateReport(this CoverageResult coverageResult,
3030
{
3131
Process.Start("cmd", "/C " + Path.GetFullPath(Path.Combine(directory, "index.htm")));
3232
}
33-
33+
Process.Start("cmd", "/C " + Path.GetFullPath(Path.Combine(directory, "index.htm")));
3434
return coverageResult;
3535
}
3636

test/coverlet.core.tests/Samples/Instrumentation.AwaitUsing.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ async private Task Issue914_Repro_Example2()
3636
await transaction.DisposeAsync();
3737
}
3838

39+
async public Task<T> Issue1490_Repro<T>()
40+
{
41+
await using var transaction = new MyTransaction();
42+
return default(T);
43+
}
44+
3945

4046
private class MyTransaction : IAsyncDisposable
4147
{

0 commit comments

Comments
 (0)