-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathClassWithMethod.cs
More file actions
62 lines (56 loc) · 1.62 KB
/
ClassWithMethod.cs
File metadata and controls
62 lines (56 loc) · 1.62 KB
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
using System;
using System.Diagnostics;
using System.Threading;
using MethodTimer;
public class ClassWithMethod
{
[Time]
public void MethodWithoutFormatting(string fileName, int id)
{
Thread.Sleep(10);
}
[Time("File name '{fileName}' with id '{id}'")]
public void Method(string fileName, int id)
{
Thread.Sleep(10);
}
public void Method_Expected(string fileName, int id)
{
var start = Stopwatch.GetTimestamp();
try
{
Thread.Sleep(10);
}
finally
{
var end = Stopwatch.GetTimestamp();
var duration = end - start;
var elapsedTimeSpan = new TimeSpan((long)(MethodTimerHelper.TimestampToTicks * duration));
var methodTimerMessage = $"File name '{fileName}' with id '{id}'";
MethodTimeLogger.Log(null, (long)elapsedTimeSpan.TotalMilliseconds, methodTimerMessage);
}
}
[Time("Current object: '{this}' | File name '{fileName}' with id '{id}'")]
public void MethodWithThis(string fileName, int id)
{
Thread.Sleep(10);
}
public void MethodWithThis_Expected(string fileName, int id)
{
var stopwatch = Stopwatch.StartNew();
try
{
Thread.Sleep(10);
}
finally
{
stopwatch.Stop();
var methodTimerMessage = $"Current object: '{this}' | File name '{fileName}' with id '{id}'";
MethodTimeLogger.Log(null, stopwatch.ElapsedMilliseconds, methodTimerMessage);
}
}
public override string ToString()
{
return "TEST VALUE";
}
}