Code Coverage Statistics for Source File
Newtonsoft.Json.Tests\TestObjects\Event.cs
Symbol Coverage: 0.00% (0 of 58)
Branch Coverage: 0.00% (0 of 28)
Cyclomatic Complexity Avg: 1.20 Max:3
Code Lines: 39
Symbol Coverage Trend
View:
L | V | Source |
---|---|---|
1 |
#region License |
|
2 |
// Copyright (c) 2007 James Newton-King |
|
3 |
// |
|
4 |
// Permission is hereby granted, free of charge, to any person |
|
5 |
// obtaining a copy of this software and associated documentation |
|
6 |
// files (the "Software"), to deal in the Software without |
|
7 |
// restriction, including without limitation the rights to use, |
|
8 |
// copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
// copies of the Software, and to permit persons to whom the |
|
10 |
// Software is furnished to do so, subject to the following |
|
11 |
// conditions: |
|
12 |
// |
|
13 |
// The above copyright notice and this permission notice shall be |
|
14 |
// included in all copies or substantial portions of the Software. |
|
15 |
// |
|
16 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
// OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
#endregion |
|
25 |
||
26 |
using System; |
|
27 |
||
28 |
namespace Newtonsoft.Json.Tests.TestObjects |
|
29 |
{ |
|
30 |
/// <summary> |
|
31 |
/// What types of events are there? Just sticking to a basic set of four for now. |
|
32 |
/// </summary> |
|
33 |
/// <remarks></remarks> |
|
34 |
public enum EventType |
|
35 |
{ |
|
36 |
Debug = 0, |
|
37 |
Info = 1, |
|
38 |
Warning = 2, |
|
39 |
Error = 3 |
|
40 |
} |
|
41 |
||
42 |
public sealed class Event |
|
43 |
{ |
|
44 |
||
45 |
/// <summary> |
|
46 |
/// If no current user is specified, returns Nothing (0 from VB) |
|
47 |
/// </summary> |
|
48 |
/// <returns></returns> |
|
49 |
/// <remarks></remarks> |
|
50 |
private static int GetCurrentUserId() |
|
51 |
{ |
|
52 |
0 |
return 0;
|
53 |
0 |
}
|
54 |
||
55 |
/// <summary> |
|
56 |
/// Gets either the application path or the current stack trace. |
|
57 |
/// NOTE: You MUST call this from the top level entry point. Otherwise, |
|
58 |
/// the stack trace will be buried in Logger itself. |
|
59 |
/// </summary> |
|
60 |
/// <returns></returns> |
|
61 |
/// <remarks></remarks> |
|
62 |
private static string GetCurrentSubLocation() |
|
63 |
{ |
|
64 |
0 |
return "";
|
65 |
0 |
}
|
66 |
||
67 |
private string _sublocation; |
|
68 |
private int _userId; |
|
69 |
private EventType _type; |
|
70 |
private string _summary; |
|
71 |
private string _details; |
|
72 |
private string _stackTrace; |
|
73 |
private string _tag; |
|
74 |
private DateTime _time; |
|
75 |
||
76 |
0 |
public Event(string summary)
|
77 |
{ |
|
78 |
0 |
_summary = summary;
|
79 |
0 |
_time = DateTime.Now;
|
80 |
||
81 |
0 |
if (_userId == 0) _userId = GetCurrentUserId();
|
82 |
//This call only works at top level for now. |
|
83 |
//If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace |
|
84 |
0 |
if (_sublocation == null) _sublocation = GetCurrentSubLocation();
|
85 |
0 |
}
|
86 |
||
87 |
0 |
public Event(string sublocation, int userId, EventType type, string summary, string details, string stackTrace, string tag)
|
88 |
{ |
|
89 |
0 |
_sublocation = sublocation;
|
90 |
0 |
_userId = userId;
|
91 |
0 |
_type = type;
|
92 |
0 |
_summary = summary;
|
93 |
0 |
_details = details;
|
94 |
0 |
_stackTrace = stackTrace;
|
95 |
0 |
_tag = tag;
|
96 |
0 |
_time = DateTime.Now;
|
97 |
||
98 |
0 |
if (_userId == 0) _userId = GetCurrentUserId();
|
99 |
//If _stackTrace = Nothing Then _stackTrace = Environment.StackTrace |
|
100 |
0 |
if (_sublocation == null) _sublocation = GetCurrentSubLocation();
|
101 |
0 |
}
|
102 |
||
103 |
public override string ToString() |
|
104 |
{ |
|
105 |
0 |
return string.Format("{{ sublocation = {0}, userId = {1}, type = {2}, summary = {3}, details = {4}, stackTrace = {5}, tag = {6} }}", _sublocation, _userId, _type, _summary, _details, _stackTrace, _tag);
|
106 |
0 |
}
|
107 |
||
108 |
public string sublocation |
|
109 |
{ |
|
110 |
0 |
get { return _sublocation; }
|
111 |
0 |
set { _sublocation = value; }
|
112 |
} |
|
113 |
public int userId |
|
114 |
{ |
|
115 |
0 |
get { return _userId; }
|
116 |
0 |
set { _userId = value; }
|
117 |
} |
|
118 |
public EventType type |
|
119 |
{ |
|
120 |
0 |
get { return _type; }
|
121 |
0 |
set { _type = value; }
|
122 |
} |
|
123 |
public string summary |
|
124 |
{ |
|
125 |
0 |
get { return _summary; }
|
126 |
0 |
set { _summary = value; }
|
127 |
} |
|
128 |
public string details |
|
129 |
{ |
|
130 |
0 |
get { return _details; }
|
131 |
0 |
set { _details = value; }
|
132 |
} |
|
133 |
public string stackTrace |
|
134 |
{ |
|
135 |
0 |
get { return _stackTrace; }
|
136 |
0 |
set { _stackTrace = value; }
|
137 |
} |
|
138 |
public string tag |
|
139 |
{ |
|
140 |
0 |
get { return _tag; }
|
141 |
0 |
set { _tag = value; }
|
142 |
} |
|
143 |
public DateTime time |
|
144 |
{ |
|
145 |
0 |
get { return _time; }
|
146 |
} |
|
147 |
} |
|
148 |
} |