application_insights 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +6 -14
  2. data/.travis.yml +21 -9
  3. data/CONTRIBUTING.md +30 -0
  4. data/Gemfile +4 -4
  5. data/LICENSE.txt +11 -11
  6. data/README.md +13 -14
  7. data/Rakefile +14 -14
  8. data/application_insights.gemspec +28 -29
  9. data/lib/application_insights.rb +9 -9
  10. data/lib/application_insights/channel/asynchronous_queue.rb +58 -51
  11. data/lib/application_insights/channel/asynchronous_sender.rb +132 -123
  12. data/lib/application_insights/channel/contracts/application.rb +14 -53
  13. data/lib/application_insights/channel/contracts/cloud.rb +14 -0
  14. data/lib/application_insights/channel/contracts/data.rb +14 -48
  15. data/lib/application_insights/channel/contracts/data_point.rb +24 -130
  16. data/lib/application_insights/channel/contracts/data_point_type.rb +7 -16
  17. data/lib/application_insights/channel/contracts/dependency_kind.rb +9 -19
  18. data/lib/application_insights/channel/contracts/dependency_source_type.rb +9 -19
  19. data/lib/application_insights/channel/contracts/device.rb +28 -257
  20. data/lib/application_insights/channel/contracts/envelope.rb +40 -266
  21. data/lib/application_insights/channel/contracts/event_data.rb +28 -77
  22. data/lib/application_insights/channel/contracts/exception_data.rb +37 -140
  23. data/lib/application_insights/channel/contracts/exception_details.rb +28 -129
  24. data/lib/application_insights/channel/contracts/internal.rb +14 -53
  25. data/lib/application_insights/channel/contracts/json_serializable.rb +59 -59
  26. data/lib/application_insights/channel/contracts/location.rb +16 -36
  27. data/lib/application_insights/channel/contracts/message_data.rb +24 -77
  28. data/lib/application_insights/channel/contracts/metric_data.rb +27 -60
  29. data/lib/application_insights/channel/contracts/operation.rb +19 -121
  30. data/lib/application_insights/channel/contracts/page_view_data.rb +30 -111
  31. data/lib/application_insights/channel/contracts/remote_dependency_data.rb +56 -260
  32. data/lib/application_insights/channel/contracts/request_data.rb +36 -176
  33. data/lib/application_insights/channel/contracts/session.rb +15 -70
  34. data/lib/application_insights/channel/contracts/severity_level.rb +13 -25
  35. data/lib/application_insights/channel/contracts/stack_frame.rb +17 -94
  36. data/lib/application_insights/channel/contracts/user.rb +19 -104
  37. data/lib/application_insights/channel/event.rb +68 -64
  38. data/lib/application_insights/channel/queue_base.rb +65 -62
  39. data/lib/application_insights/channel/sender_base.rb +79 -72
  40. data/lib/application_insights/channel/synchronous_queue.rb +45 -39
  41. data/lib/application_insights/channel/synchronous_sender.rb +17 -15
  42. data/lib/application_insights/channel/telemetry_channel.rb +120 -102
  43. data/lib/application_insights/channel/telemetry_context.rb +85 -68
  44. data/lib/application_insights/rack/track_request.rb +87 -84
  45. data/lib/application_insights/telemetry_client.rb +229 -217
  46. data/lib/application_insights/unhandled_exception.rb +49 -47
  47. data/lib/application_insights/version.rb +3 -3
  48. data/test/application_insights.rb +8 -9
  49. data/test/application_insights/channel/contracts/test_application.rb +44 -44
  50. data/test/application_insights/channel/contracts/test_cloud.rb +44 -0
  51. data/test/application_insights/channel/contracts/test_data.rb +44 -44
  52. data/test/application_insights/channel/contracts/test_data_point.rb +109 -109
  53. data/test/application_insights/channel/contracts/test_device.rb +200 -200
  54. data/test/application_insights/channel/contracts/test_envelope.rb +209 -209
  55. data/test/application_insights/channel/contracts/test_event_data.rb +62 -62
  56. data/test/application_insights/channel/contracts/test_exception_data.rb +111 -111
  57. data/test/application_insights/channel/contracts/test_exception_details.rb +106 -106
  58. data/test/application_insights/channel/contracts/test_internal.rb +44 -44
  59. data/test/application_insights/channel/contracts/test_location.rb +70 -31
  60. data/test/application_insights/channel/contracts/test_message_data.rb +66 -66
  61. data/test/application_insights/channel/contracts/test_metric_data.rb +50 -50
  62. data/test/application_insights/channel/contracts/test_operation.rb +109 -96
  63. data/test/application_insights/channel/contracts/test_page_view_data.rb +88 -88
  64. data/test/application_insights/channel/contracts/test_remote_dependency_data.rb +209 -209
  65. data/test/application_insights/channel/contracts/test_request_data.rb +153 -153
  66. data/test/application_insights/channel/contracts/test_session.rb +57 -57
  67. data/test/application_insights/channel/contracts/test_stack_frame.rb +83 -83
  68. data/test/application_insights/channel/contracts/test_user.rb +96 -83
  69. data/test/application_insights/channel/test_asynchronous_queue.rb +47 -47
  70. data/test/application_insights/channel/test_asynchronous_sender.rb +80 -80
  71. data/test/application_insights/channel/test_event.rb +52 -52
  72. data/test/application_insights/channel/test_queue_base.rb +88 -88
  73. data/test/application_insights/channel/test_sender_base.rb +87 -87
  74. data/test/application_insights/channel/test_synchronous_queue.rb +27 -27
  75. data/test/application_insights/channel/test_synchronous_sender.rb +10 -10
  76. data/test/application_insights/channel/test_telemetry_channel.rb +126 -102
  77. data/test/application_insights/channel/test_telemetry_context.rb +82 -74
  78. data/test/application_insights/mock_sender.rb +37 -37
  79. data/test/application_insights/rack/test_track_request.rb +142 -139
  80. data/test/application_insights/test_telemetry_client.rb +133 -123
  81. data/test/application_insights/test_unhandled_exception.rb +23 -24
  82. metadata +23 -33
@@ -1,200 +1,200 @@
1
- require_relative '../../../../lib/application_insights/channel/contracts/device'
2
- require 'test/unit'
3
-
4
- include ApplicationInsights::Channel
5
-
6
- class TestDevice < Test::Unit::TestCase
7
- def test_initialize
8
- item = Contracts::Device.new
9
- assert_not_nil item
10
- end
11
-
12
- def test_id_works_as_expected
13
- expected = 'Test string'
14
- item = Contracts::Device.new
15
- item.id = expected
16
- actual = item.id
17
- assert_equal expected, actual
18
- expected = 'Other string'
19
- item.id = expected
20
- actual = item.id
21
- assert_equal expected, actual
22
- end
23
-
24
- def test_ip_works_as_expected
25
- expected = 'Test string'
26
- item = Contracts::Device.new
27
- item.ip = expected
28
- actual = item.ip
29
- assert_equal expected, actual
30
- expected = 'Other string'
31
- item.ip = expected
32
- actual = item.ip
33
- assert_equal expected, actual
34
- end
35
-
36
- def test_language_works_as_expected
37
- expected = 'Test string'
38
- item = Contracts::Device.new
39
- item.language = expected
40
- actual = item.language
41
- assert_equal expected, actual
42
- expected = 'Other string'
43
- item.language = expected
44
- actual = item.language
45
- assert_equal expected, actual
46
- end
47
-
48
- def test_locale_works_as_expected
49
- expected = 'Test string'
50
- item = Contracts::Device.new
51
- item.locale = expected
52
- actual = item.locale
53
- assert_equal expected, actual
54
- expected = 'Other string'
55
- item.locale = expected
56
- actual = item.locale
57
- assert_equal expected, actual
58
- end
59
-
60
- def test_model_works_as_expected
61
- expected = 'Test string'
62
- item = Contracts::Device.new
63
- item.model = expected
64
- actual = item.model
65
- assert_equal expected, actual
66
- expected = 'Other string'
67
- item.model = expected
68
- actual = item.model
69
- assert_equal expected, actual
70
- end
71
-
72
- def test_network_works_as_expected
73
- expected = 'Test string'
74
- item = Contracts::Device.new
75
- item.network = expected
76
- actual = item.network
77
- assert_equal expected, actual
78
- expected = 'Other string'
79
- item.network = expected
80
- actual = item.network
81
- assert_equal expected, actual
82
- end
83
-
84
- def test_oem_name_works_as_expected
85
- expected = 'Test string'
86
- item = Contracts::Device.new
87
- item.oem_name = expected
88
- actual = item.oem_name
89
- assert_equal expected, actual
90
- expected = 'Other string'
91
- item.oem_name = expected
92
- actual = item.oem_name
93
- assert_equal expected, actual
94
- end
95
-
96
- def test_os_works_as_expected
97
- expected = 'Test string'
98
- item = Contracts::Device.new
99
- item.os = expected
100
- actual = item.os
101
- assert_equal expected, actual
102
- expected = 'Other string'
103
- item.os = expected
104
- actual = item.os
105
- assert_equal expected, actual
106
- end
107
-
108
- def test_os_version_works_as_expected
109
- expected = 'Test string'
110
- item = Contracts::Device.new
111
- item.os_version = expected
112
- actual = item.os_version
113
- assert_equal expected, actual
114
- expected = 'Other string'
115
- item.os_version = expected
116
- actual = item.os_version
117
- assert_equal expected, actual
118
- end
119
-
120
- def test_role_instance_works_as_expected
121
- expected = 'Test string'
122
- item = Contracts::Device.new
123
- item.role_instance = expected
124
- actual = item.role_instance
125
- assert_equal expected, actual
126
- expected = 'Other string'
127
- item.role_instance = expected
128
- actual = item.role_instance
129
- assert_equal expected, actual
130
- end
131
-
132
- def test_role_name_works_as_expected
133
- expected = 'Test string'
134
- item = Contracts::Device.new
135
- item.role_name = expected
136
- actual = item.role_name
137
- assert_equal expected, actual
138
- expected = 'Other string'
139
- item.role_name = expected
140
- actual = item.role_name
141
- assert_equal expected, actual
142
- end
143
-
144
- def test_screen_resolution_works_as_expected
145
- expected = 'Test string'
146
- item = Contracts::Device.new
147
- item.screen_resolution = expected
148
- actual = item.screen_resolution
149
- assert_equal expected, actual
150
- expected = 'Other string'
151
- item.screen_resolution = expected
152
- actual = item.screen_resolution
153
- assert_equal expected, actual
154
- end
155
-
156
- def test_type_works_as_expected
157
- expected = 'Test string'
158
- item = Contracts::Device.new
159
- item.type = expected
160
- actual = item.type
161
- assert_equal expected, actual
162
- expected = 'Other string'
163
- item.type = expected
164
- actual = item.type
165
- assert_equal expected, actual
166
- end
167
-
168
- def test_machine_name_works_as_expected
169
- expected = 'Test string'
170
- item = Contracts::Device.new
171
- item.machine_name = expected
172
- actual = item.machine_name
173
- assert_equal expected, actual
174
- expected = 'Other string'
175
- item.machine_name = expected
176
- actual = item.machine_name
177
- assert_equal expected, actual
178
- end
179
-
180
- def test_to_json_works_as_expected
181
- item = Contracts::Device.new
182
- item.id = 'Test string'
183
- item.ip = 'Test string'
184
- item.language = 'Test string'
185
- item.locale = 'Test string'
186
- item.model = 'Test string'
187
- item.network = 'Test string'
188
- item.oem_name = 'Test string'
189
- item.os = 'Test string'
190
- item.os_version = 'Test string'
191
- item.role_instance = 'Test string'
192
- item.role_name = 'Test string'
193
- item.screen_resolution = 'Test string'
194
- item.type = 'Test string'
195
- item.machine_name = 'Test string'
196
- actual = item.to_json
197
- expected = '{"ai.device.id":"Test string","ai.device.ip":"Test string","ai.device.language":"Test string","ai.device.locale":"Test string","ai.device.model":"Test string","ai.device.network":"Test string","ai.device.oemName":"Test string","ai.device.os":"Test string","ai.device.osVersion":"Test string","ai.device.roleInstance":"Test string","ai.device.roleName":"Test string","ai.device.screenResolution":"Test string","ai.device.type":"Test string","ai.device.machineName":"Test string"}'
198
- assert_equal expected, actual
199
- end
200
- end
1
+ require_relative '../../../../lib/application_insights/channel/contracts/device'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestDevice < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::Device.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_id_works_as_expected
13
+ expected = 'Test string'
14
+ item = Contracts::Device.new
15
+ item.id = expected
16
+ actual = item.id
17
+ assert_equal expected, actual
18
+ expected = 'Other string'
19
+ item.id = expected
20
+ actual = item.id
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_ip_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::Device.new
27
+ item.ip = expected
28
+ actual = item.ip
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.ip = expected
32
+ actual = item.ip
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_language_works_as_expected
37
+ expected = 'Test string'
38
+ item = Contracts::Device.new
39
+ item.language = expected
40
+ actual = item.language
41
+ assert_equal expected, actual
42
+ expected = 'Other string'
43
+ item.language = expected
44
+ actual = item.language
45
+ assert_equal expected, actual
46
+ end
47
+
48
+ def test_locale_works_as_expected
49
+ expected = 'Test string'
50
+ item = Contracts::Device.new
51
+ item.locale = expected
52
+ actual = item.locale
53
+ assert_equal expected, actual
54
+ expected = 'Other string'
55
+ item.locale = expected
56
+ actual = item.locale
57
+ assert_equal expected, actual
58
+ end
59
+
60
+ def test_model_works_as_expected
61
+ expected = 'Test string'
62
+ item = Contracts::Device.new
63
+ item.model = expected
64
+ actual = item.model
65
+ assert_equal expected, actual
66
+ expected = 'Other string'
67
+ item.model = expected
68
+ actual = item.model
69
+ assert_equal expected, actual
70
+ end
71
+
72
+ def test_network_works_as_expected
73
+ expected = 'Test string'
74
+ item = Contracts::Device.new
75
+ item.network = expected
76
+ actual = item.network
77
+ assert_equal expected, actual
78
+ expected = 'Other string'
79
+ item.network = expected
80
+ actual = item.network
81
+ assert_equal expected, actual
82
+ end
83
+
84
+ def test_oem_name_works_as_expected
85
+ expected = 'Test string'
86
+ item = Contracts::Device.new
87
+ item.oem_name = expected
88
+ actual = item.oem_name
89
+ assert_equal expected, actual
90
+ expected = 'Other string'
91
+ item.oem_name = expected
92
+ actual = item.oem_name
93
+ assert_equal expected, actual
94
+ end
95
+
96
+ def test_os_works_as_expected
97
+ expected = 'Test string'
98
+ item = Contracts::Device.new
99
+ item.os = expected
100
+ actual = item.os
101
+ assert_equal expected, actual
102
+ expected = 'Other string'
103
+ item.os = expected
104
+ actual = item.os
105
+ assert_equal expected, actual
106
+ end
107
+
108
+ def test_os_version_works_as_expected
109
+ expected = 'Test string'
110
+ item = Contracts::Device.new
111
+ item.os_version = expected
112
+ actual = item.os_version
113
+ assert_equal expected, actual
114
+ expected = 'Other string'
115
+ item.os_version = expected
116
+ actual = item.os_version
117
+ assert_equal expected, actual
118
+ end
119
+
120
+ def test_role_instance_works_as_expected
121
+ expected = 'Test string'
122
+ item = Contracts::Device.new
123
+ item.role_instance = expected
124
+ actual = item.role_instance
125
+ assert_equal expected, actual
126
+ expected = 'Other string'
127
+ item.role_instance = expected
128
+ actual = item.role_instance
129
+ assert_equal expected, actual
130
+ end
131
+
132
+ def test_role_name_works_as_expected
133
+ expected = 'Test string'
134
+ item = Contracts::Device.new
135
+ item.role_name = expected
136
+ actual = item.role_name
137
+ assert_equal expected, actual
138
+ expected = 'Other string'
139
+ item.role_name = expected
140
+ actual = item.role_name
141
+ assert_equal expected, actual
142
+ end
143
+
144
+ def test_screen_resolution_works_as_expected
145
+ expected = 'Test string'
146
+ item = Contracts::Device.new
147
+ item.screen_resolution = expected
148
+ actual = item.screen_resolution
149
+ assert_equal expected, actual
150
+ expected = 'Other string'
151
+ item.screen_resolution = expected
152
+ actual = item.screen_resolution
153
+ assert_equal expected, actual
154
+ end
155
+
156
+ def test_type_works_as_expected
157
+ expected = 'Test string'
158
+ item = Contracts::Device.new
159
+ item.type = expected
160
+ actual = item.type
161
+ assert_equal expected, actual
162
+ expected = 'Other string'
163
+ item.type = expected
164
+ actual = item.type
165
+ assert_equal expected, actual
166
+ end
167
+
168
+ def test_machine_name_works_as_expected
169
+ expected = 'Test string'
170
+ item = Contracts::Device.new
171
+ item.machine_name = expected
172
+ actual = item.machine_name
173
+ assert_equal expected, actual
174
+ expected = 'Other string'
175
+ item.machine_name = expected
176
+ actual = item.machine_name
177
+ assert_equal expected, actual
178
+ end
179
+
180
+ def test_to_json_works_as_expected
181
+ item = Contracts::Device.new
182
+ item.id = 'Test string'
183
+ item.ip = 'Test string'
184
+ item.language = 'Test string'
185
+ item.locale = 'Test string'
186
+ item.model = 'Test string'
187
+ item.network = 'Test string'
188
+ item.oem_name = 'Test string'
189
+ item.os = 'Test string'
190
+ item.os_version = 'Test string'
191
+ item.role_instance = 'Test string'
192
+ item.role_name = 'Test string'
193
+ item.screen_resolution = 'Test string'
194
+ item.type = 'Test string'
195
+ item.machine_name = 'Test string'
196
+ actual = item.to_json
197
+ expected = '{"ai.device.id":"Test string","ai.device.ip":"Test string","ai.device.language":"Test string","ai.device.locale":"Test string","ai.device.model":"Test string","ai.device.network":"Test string","ai.device.oemName":"Test string","ai.device.os":"Test string","ai.device.osVersion":"Test string","ai.device.roleInstance":"Test string","ai.device.roleName":"Test string","ai.device.screenResolution":"Test string","ai.device.type":"Test string","ai.device.machineName":"Test string"}'
198
+ assert_equal expected, actual
199
+ end
200
+ end
@@ -1,209 +1,209 @@
1
- require_relative '../../../../lib/application_insights/channel/contracts/envelope'
2
- require 'test/unit'
3
-
4
- include ApplicationInsights::Channel
5
-
6
- class TestEnvelope < Test::Unit::TestCase
7
- def test_initialize
8
- item = Contracts::Envelope.new
9
- assert_not_nil item
10
- end
11
-
12
- def test_ver_works_as_expected
13
- expected = 42
14
- item = Contracts::Envelope.new
15
- item.ver = expected
16
- actual = item.ver
17
- assert_equal expected, actual
18
- expected = 13
19
- item.ver = expected
20
- actual = item.ver
21
- assert_equal expected, actual
22
- end
23
-
24
- def test_name_works_as_expected
25
- expected = 'Test string'
26
- item = Contracts::Envelope.new
27
- item.name = expected
28
- actual = item.name
29
- assert_equal expected, actual
30
- expected = 'Other string'
31
- item.name = expected
32
- actual = item.name
33
- assert_equal expected, actual
34
- end
35
-
36
- def test_time_works_as_expected
37
- expected = 'Test string'
38
- item = Contracts::Envelope.new
39
- item.time = expected
40
- actual = item.time
41
- assert_equal expected, actual
42
- expected = 'Other string'
43
- item.time = expected
44
- actual = item.time
45
- assert_equal expected, actual
46
- end
47
-
48
- def test_sample_rate_works_as_expected
49
- expected = 1.5
50
- item = Contracts::Envelope.new
51
- item.sample_rate = expected
52
- actual = item.sample_rate
53
- assert_equal expected, actual
54
- expected = 4.8
55
- item.sample_rate = expected
56
- actual = item.sample_rate
57
- assert_equal expected, actual
58
- end
59
-
60
- def test_seq_works_as_expected
61
- expected = 'Test string'
62
- item = Contracts::Envelope.new
63
- item.seq = expected
64
- actual = item.seq
65
- assert_equal expected, actual
66
- expected = 'Other string'
67
- item.seq = expected
68
- actual = item.seq
69
- assert_equal expected, actual
70
- end
71
-
72
- def test_i_key_works_as_expected
73
- expected = 'Test string'
74
- item = Contracts::Envelope.new
75
- item.i_key = expected
76
- actual = item.i_key
77
- assert_equal expected, actual
78
- expected = 'Other string'
79
- item.i_key = expected
80
- actual = item.i_key
81
- assert_equal expected, actual
82
- end
83
-
84
- def test_flags_works_as_expected
85
- expected = 42
86
- item = Contracts::Envelope.new
87
- item.flags = expected
88
- actual = item.flags
89
- assert_equal expected, actual
90
- expected = 13
91
- item.flags = expected
92
- actual = item.flags
93
- assert_equal expected, actual
94
- end
95
-
96
- def test_device_id_works_as_expected
97
- expected = 'Test string'
98
- item = Contracts::Envelope.new
99
- item.device_id = expected
100
- actual = item.device_id
101
- assert_equal expected, actual
102
- expected = 'Other string'
103
- item.device_id = expected
104
- actual = item.device_id
105
- assert_equal expected, actual
106
- end
107
-
108
- def test_os_works_as_expected
109
- expected = 'Test string'
110
- item = Contracts::Envelope.new
111
- item.os = expected
112
- actual = item.os
113
- assert_equal expected, actual
114
- expected = 'Other string'
115
- item.os = expected
116
- actual = item.os
117
- assert_equal expected, actual
118
- end
119
-
120
- def test_os_ver_works_as_expected
121
- expected = 'Test string'
122
- item = Contracts::Envelope.new
123
- item.os_ver = expected
124
- actual = item.os_ver
125
- assert_equal expected, actual
126
- expected = 'Other string'
127
- item.os_ver = expected
128
- actual = item.os_ver
129
- assert_equal expected, actual
130
- end
131
-
132
- def test_app_id_works_as_expected
133
- expected = 'Test string'
134
- item = Contracts::Envelope.new
135
- item.app_id = expected
136
- actual = item.app_id
137
- assert_equal expected, actual
138
- expected = 'Other string'
139
- item.app_id = expected
140
- actual = item.app_id
141
- assert_equal expected, actual
142
- end
143
-
144
- def test_app_ver_works_as_expected
145
- expected = 'Test string'
146
- item = Contracts::Envelope.new
147
- item.app_ver = expected
148
- actual = item.app_ver
149
- assert_equal expected, actual
150
- expected = 'Other string'
151
- item.app_ver = expected
152
- actual = item.app_ver
153
- assert_equal expected, actual
154
- end
155
-
156
- def test_user_id_works_as_expected
157
- expected = 'Test string'
158
- item = Contracts::Envelope.new
159
- item.user_id = expected
160
- actual = item.user_id
161
- assert_equal expected, actual
162
- expected = 'Other string'
163
- item.user_id = expected
164
- actual = item.user_id
165
- assert_equal expected, actual
166
- end
167
-
168
- def test_tags_works_as_expected
169
- item = Contracts::Envelope.new
170
- actual = item.tags
171
- assert_not_nil actual
172
- end
173
-
174
- def test_data_works_as_expected
175
- expected = { 'key' => 'value' }
176
- item = Contracts::Envelope.new
177
- item.data = expected
178
- actual = item.data
179
- assert_equal expected, actual
180
- expected = { 'key' => 'value' }
181
- item.data = expected
182
- actual = item.data
183
- assert_equal expected, actual
184
- end
185
-
186
- def test_to_json_works_as_expected
187
- item = Contracts::Envelope.new
188
- item.ver = 42
189
- item.name = 'Test string'
190
- item.time = 'Test string'
191
- item.sample_rate = 1.5
192
- item.seq = 'Test string'
193
- item.i_key = 'Test string'
194
- item.flags = 42
195
- item.device_id = 'Test string'
196
- item.os = 'Test string'
197
- item.os_ver = 'Test string'
198
- item.app_id = 'Test string'
199
- item.app_ver = 'Test string'
200
- item.user_id = 'Test string'
201
- { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|
202
- item.tags[key] = value
203
- end
204
- item.data = { 'key' => 'value' }
205
- actual = item.to_json
206
- expected = '{"ver":42,"name":"Test string","time":"Test string","sampleRate":1.5,"seq":"Test string","iKey":"Test string","flags":42,"deviceId":"Test string","os":"Test string","osVer":"Test string","appId":"Test string","appVer":"Test string","userId":"Test string","tags":{"key1":"test value 1","key2":"test value 2"},"data":{"key":"value"}}'
207
- assert_equal expected, actual
208
- end
209
- end
1
+ require_relative '../../../../lib/application_insights/channel/contracts/envelope'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestEnvelope < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::Envelope.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_ver_works_as_expected
13
+ expected = 42
14
+ item = Contracts::Envelope.new
15
+ item.ver = expected
16
+ actual = item.ver
17
+ assert_equal expected, actual
18
+ expected = 13
19
+ item.ver = expected
20
+ actual = item.ver
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_name_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::Envelope.new
27
+ item.name = expected
28
+ actual = item.name
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.name = expected
32
+ actual = item.name
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_time_works_as_expected
37
+ expected = 'Test string'
38
+ item = Contracts::Envelope.new
39
+ item.time = expected
40
+ actual = item.time
41
+ assert_equal expected, actual
42
+ expected = 'Other string'
43
+ item.time = expected
44
+ actual = item.time
45
+ assert_equal expected, actual
46
+ end
47
+
48
+ def test_sample_rate_works_as_expected
49
+ expected = 1.5
50
+ item = Contracts::Envelope.new
51
+ item.sample_rate = expected
52
+ actual = item.sample_rate
53
+ assert_equal expected, actual
54
+ expected = 4.8
55
+ item.sample_rate = expected
56
+ actual = item.sample_rate
57
+ assert_equal expected, actual
58
+ end
59
+
60
+ def test_seq_works_as_expected
61
+ expected = 'Test string'
62
+ item = Contracts::Envelope.new
63
+ item.seq = expected
64
+ actual = item.seq
65
+ assert_equal expected, actual
66
+ expected = 'Other string'
67
+ item.seq = expected
68
+ actual = item.seq
69
+ assert_equal expected, actual
70
+ end
71
+
72
+ def test_i_key_works_as_expected
73
+ expected = 'Test string'
74
+ item = Contracts::Envelope.new
75
+ item.i_key = expected
76
+ actual = item.i_key
77
+ assert_equal expected, actual
78
+ expected = 'Other string'
79
+ item.i_key = expected
80
+ actual = item.i_key
81
+ assert_equal expected, actual
82
+ end
83
+
84
+ def test_flags_works_as_expected
85
+ expected = 42
86
+ item = Contracts::Envelope.new
87
+ item.flags = expected
88
+ actual = item.flags
89
+ assert_equal expected, actual
90
+ expected = 13
91
+ item.flags = expected
92
+ actual = item.flags
93
+ assert_equal expected, actual
94
+ end
95
+
96
+ def test_device_id_works_as_expected
97
+ expected = 'Test string'
98
+ item = Contracts::Envelope.new
99
+ item.device_id = expected
100
+ actual = item.device_id
101
+ assert_equal expected, actual
102
+ expected = 'Other string'
103
+ item.device_id = expected
104
+ actual = item.device_id
105
+ assert_equal expected, actual
106
+ end
107
+
108
+ def test_os_works_as_expected
109
+ expected = 'Test string'
110
+ item = Contracts::Envelope.new
111
+ item.os = expected
112
+ actual = item.os
113
+ assert_equal expected, actual
114
+ expected = 'Other string'
115
+ item.os = expected
116
+ actual = item.os
117
+ assert_equal expected, actual
118
+ end
119
+
120
+ def test_os_ver_works_as_expected
121
+ expected = 'Test string'
122
+ item = Contracts::Envelope.new
123
+ item.os_ver = expected
124
+ actual = item.os_ver
125
+ assert_equal expected, actual
126
+ expected = 'Other string'
127
+ item.os_ver = expected
128
+ actual = item.os_ver
129
+ assert_equal expected, actual
130
+ end
131
+
132
+ def test_app_id_works_as_expected
133
+ expected = 'Test string'
134
+ item = Contracts::Envelope.new
135
+ item.app_id = expected
136
+ actual = item.app_id
137
+ assert_equal expected, actual
138
+ expected = 'Other string'
139
+ item.app_id = expected
140
+ actual = item.app_id
141
+ assert_equal expected, actual
142
+ end
143
+
144
+ def test_app_ver_works_as_expected
145
+ expected = 'Test string'
146
+ item = Contracts::Envelope.new
147
+ item.app_ver = expected
148
+ actual = item.app_ver
149
+ assert_equal expected, actual
150
+ expected = 'Other string'
151
+ item.app_ver = expected
152
+ actual = item.app_ver
153
+ assert_equal expected, actual
154
+ end
155
+
156
+ def test_user_id_works_as_expected
157
+ expected = 'Test string'
158
+ item = Contracts::Envelope.new
159
+ item.user_id = expected
160
+ actual = item.user_id
161
+ assert_equal expected, actual
162
+ expected = 'Other string'
163
+ item.user_id = expected
164
+ actual = item.user_id
165
+ assert_equal expected, actual
166
+ end
167
+
168
+ def test_tags_works_as_expected
169
+ item = Contracts::Envelope.new
170
+ actual = item.tags
171
+ assert_not_nil actual
172
+ end
173
+
174
+ def test_data_works_as_expected
175
+ expected = { 'key' => 'value' }
176
+ item = Contracts::Envelope.new
177
+ item.data = expected
178
+ actual = item.data
179
+ assert_equal expected, actual
180
+ expected = { 'key' => 'value' }
181
+ item.data = expected
182
+ actual = item.data
183
+ assert_equal expected, actual
184
+ end
185
+
186
+ def test_to_json_works_as_expected
187
+ item = Contracts::Envelope.new
188
+ item.ver = 42
189
+ item.name = 'Test string'
190
+ item.time = 'Test string'
191
+ item.sample_rate = 1.5
192
+ item.seq = 'Test string'
193
+ item.i_key = 'Test string'
194
+ item.flags = 42
195
+ item.device_id = 'Test string'
196
+ item.os = 'Test string'
197
+ item.os_ver = 'Test string'
198
+ item.app_id = 'Test string'
199
+ item.app_ver = 'Test string'
200
+ item.user_id = 'Test string'
201
+ { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|
202
+ item.tags[key] = value
203
+ end
204
+ item.data = { 'key' => 'value' }
205
+ actual = item.to_json
206
+ expected = '{"ver":42,"name":"Test string","time":"Test string","sampleRate":1.5,"seq":"Test string","iKey":"Test string","flags":42,"deviceId":"Test string","os":"Test string","osVer":"Test string","appId":"Test string","appVer":"Test string","userId":"Test string","tags":{"key1":"test value 1","key2":"test value 2"},"data":{"key":"value"}}'
207
+ assert_equal expected, actual
208
+ end
209
+ end