-
Notifications
You must be signed in to change notification settings - Fork 31
/
MethodAnalyticsTests.cs
65 lines (53 loc) · 1.8 KB
/
MethodAnalyticsTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using com.csutil.analytics;
using System.Linq;
using Xunit;
namespace com.csutil.integrationTests {
public class MethodAnalyticsTests {
public MethodAnalyticsTests(Xunit.Abstractions.ITestOutputHelper logger) { logger.UseAsLoggingOutput(); }
[Fact]
public void ExampleUsage1() {
var methodAnalytics = new MethodAnalytics() { includeMethodArguments = true };
StopwatchV2 t = Log.MethodEntered();
MyMethod1(true);
Log.MethodDone(t);
string report = methodAnalytics.ToString();
Assert.True(1500 < report.Count(), "report.Count: " + report.Count());
Log.d(report);
}
[Fact]
public void ExampleUsage2() {
var methodAnalytics = new MethodAnalytics();
var t = Log.MethodEntered();
MyMethod4("1");
MyMethod4("2");
MyMethod4("3");
MyMethod4("4");
MyMethod3("5");
Log.MethodDone(t);
var report = methodAnalytics.ToString();
Assert.True(500 < report.Count(), "report.Count: " + report.Count());
}
private void MyMethod1(bool v) {
using (Log.MethodEnteredWith(v)) {
MyMethod2(10);
MyMethod3("abc");
if (v) { MyMethod1(false); }
}
}
private void MyMethod2(int i) {
using (Log.MethodEnteredWith(i)) {
MyMethod3("abc");
MyMethod3("" + i);
}
}
private string MyMethod3(string s) {
using (Log.MethodEnteredWith(s)) {
return s + "def";
}
}
private string MyMethod4(string s) {
Log.MethodEnteredWith(s);
return s + "def";
}
}
}