@@ -18,35 +18,35 @@ public TelemetryCommonPropertiesTests(ITestOutputHelper log) : base(log)
18
18
public void TelemetryCommonPropertiesShouldContainIfItIsInDockerOrNot ( )
19
19
{
20
20
var unitUnderTest = new TelemetryCommonProperties ( userLevelCacheWriter : new NothingCache ( ) ) ;
21
- unitUnderTest . GetTelemetryCommonProperties ( ) . Should ( ) . ContainKey ( "Docker Container" ) ;
21
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) . Should ( ) . ContainKey ( "Docker Container" ) ;
22
22
}
23
23
24
24
[ Fact ]
25
25
public void TelemetryCommonPropertiesShouldReturnHashedPath ( )
26
26
{
27
27
var unitUnderTest = new TelemetryCommonProperties ( ( ) => "ADirectory" , userLevelCacheWriter : new NothingCache ( ) ) ;
28
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Current Path Hash" ] . Should ( ) . NotBe ( "ADirectory" ) ;
28
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Current Path Hash" ] . Should ( ) . NotBe ( "ADirectory" ) ;
29
29
}
30
30
31
31
[ Fact ]
32
32
public void TelemetryCommonPropertiesShouldReturnHashedMachineId ( )
33
33
{
34
34
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => "plaintext" , userLevelCacheWriter : new NothingCache ( ) ) ;
35
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Machine ID" ] . Should ( ) . NotBe ( "plaintext" ) ;
35
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Machine ID" ] . Should ( ) . NotBe ( "plaintext" ) ;
36
36
}
37
37
38
38
[ Fact ]
39
39
public void TelemetryCommonPropertiesShouldReturnDevDeviceId ( )
40
40
{
41
41
var unitUnderTest = new TelemetryCommonProperties ( getDeviceId : ( ) => "plaintext" , userLevelCacheWriter : new NothingCache ( ) ) ;
42
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "devdeviceid" ] . Should ( ) . Be ( "plaintext" ) ;
42
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "devdeviceid" ] . Should ( ) . Be ( "plaintext" ) ;
43
43
}
44
44
45
45
[ Fact ]
46
46
public void TelemetryCommonPropertiesShouldReturnNewGuidWhenCannotGetMacAddress ( )
47
47
{
48
48
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
49
- var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( ) [ "Machine ID" ] ;
49
+ var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Machine ID" ] ;
50
50
51
51
Guid . TryParse ( assignedMachineId , out var _ ) . Should ( ) . BeTrue ( "it should be a guid" ) ;
52
52
}
@@ -55,10 +55,10 @@ public void TelemetryCommonPropertiesShouldReturnNewGuidWhenCannotGetMacAddress(
55
55
public void TelemetryCommonPropertiesShouldEnsureDevDeviceIDIsCached ( )
56
56
{
57
57
var unitUnderTest = new TelemetryCommonProperties ( userLevelCacheWriter : new NothingCache ( ) ) ;
58
- var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( ) [ "devdeviceid" ] ;
58
+ var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "devdeviceid" ] ;
59
59
60
60
Guid . TryParse ( assignedMachineId , out var _ ) . Should ( ) . BeTrue ( "it should be a guid" ) ;
61
- var secondAssignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( ) [ "devdeviceid" ] ;
61
+ var secondAssignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "devdeviceid" ] ;
62
62
63
63
Guid . TryParse ( secondAssignedMachineId , out var _ ) . Should ( ) . BeTrue ( "it should be a guid" ) ;
64
64
secondAssignedMachineId . Should ( ) . Be ( assignedMachineId , "it should match the previously assigned guid" ) ;
@@ -68,14 +68,14 @@ public void TelemetryCommonPropertiesShouldEnsureDevDeviceIDIsCached()
68
68
public void TelemetryCommonPropertiesShouldReturnHashedMachineIdOld ( )
69
69
{
70
70
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => "plaintext" , userLevelCacheWriter : new NothingCache ( ) ) ;
71
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Machine ID Old" ] . Should ( ) . NotBe ( "plaintext" ) ;
71
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Machine ID Old" ] . Should ( ) . NotBe ( "plaintext" ) ;
72
72
}
73
73
74
74
[ Fact ]
75
75
public void TelemetryCommonPropertiesShouldReturnNewGuidWhenCannotGetMacAddressOld ( )
76
76
{
77
77
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
78
- var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( ) [ "Machine ID Old" ] ;
78
+ var assignedMachineId = unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Machine ID Old" ] ;
79
79
80
80
Guid . TryParse ( assignedMachineId , out var _ ) . Should ( ) . BeTrue ( "it should be a guid" ) ;
81
81
}
@@ -84,72 +84,72 @@ public void TelemetryCommonPropertiesShouldReturnNewGuidWhenCannotGetMacAddressO
84
84
public void TelemetryCommonPropertiesShouldReturnIsOutputRedirected ( )
85
85
{
86
86
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
87
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Output Redirected" ] . Should ( ) . BeOneOf ( "True" , "False" ) ;
87
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Output Redirected" ] . Should ( ) . BeOneOf ( "True" , "False" ) ;
88
88
}
89
89
90
90
[ Fact ]
91
91
public void TelemetryCommonPropertiesShouldReturnIsCIDetection ( )
92
92
{
93
93
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
94
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Continuous Integration" ] . Should ( ) . BeOneOf ( "True" , "False" ) ;
94
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Continuous Integration" ] . Should ( ) . BeOneOf ( "True" , "False" ) ;
95
95
}
96
96
97
97
[ Fact ]
98
98
public void TelemetryCommonPropertiesShouldContainKernelVersion ( )
99
99
{
100
100
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
101
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Kernel Version" ] . Should ( ) . Be ( RuntimeInformation . OSDescription ) ;
101
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Kernel Version" ] . Should ( ) . Be ( RuntimeInformation . OSDescription ) ;
102
102
}
103
103
104
104
[ Fact ]
105
105
public void TelemetryCommonPropertiesShouldContainArchitectureInformation ( )
106
106
{
107
107
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
108
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "OS Architecture" ] . Should ( ) . Be ( RuntimeInformation . OSArchitecture . ToString ( ) ) ;
108
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "OS Architecture" ] . Should ( ) . Be ( RuntimeInformation . OSArchitecture . ToString ( ) ) ;
109
109
}
110
110
111
111
[ WindowsOnlyFact ]
112
112
public void TelemetryCommonPropertiesShouldContainWindowsInstallType ( )
113
113
{
114
114
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
115
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Installation Type" ] . Should ( ) . NotBeEmpty ( ) ;
115
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Installation Type" ] . Should ( ) . NotBeEmpty ( ) ;
116
116
}
117
117
118
118
[ UnixOnlyFact ]
119
119
public void TelemetryCommonPropertiesShouldContainEmptyWindowsInstallType ( )
120
120
{
121
121
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
122
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Installation Type" ] . Should ( ) . BeEmpty ( ) ;
122
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Installation Type" ] . Should ( ) . BeEmpty ( ) ;
123
123
}
124
124
125
125
[ WindowsOnlyFact ]
126
126
public void TelemetryCommonPropertiesShouldContainWindowsProductType ( )
127
127
{
128
128
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
129
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Product Type" ] . Should ( ) . NotBeEmpty ( ) ;
129
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Product Type" ] . Should ( ) . NotBeEmpty ( ) ;
130
130
}
131
131
132
132
[ UnixOnlyFact ]
133
133
public void TelemetryCommonPropertiesShouldContainEmptyWindowsProductType ( )
134
134
{
135
135
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
136
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Product Type" ] . Should ( ) . BeEmpty ( ) ;
136
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Product Type" ] . Should ( ) . BeEmpty ( ) ;
137
137
}
138
138
139
139
[ WindowsOnlyFact ]
140
140
public void TelemetryCommonPropertiesShouldContainEmptyLibcReleaseAndVersion ( )
141
141
{
142
142
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
143
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Release" ] . Should ( ) . BeEmpty ( ) ;
144
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Version" ] . Should ( ) . BeEmpty ( ) ;
143
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Release" ] . Should ( ) . BeEmpty ( ) ;
144
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Version" ] . Should ( ) . BeEmpty ( ) ;
145
145
}
146
146
147
147
[ MacOsOnlyFact ]
148
148
public void TelemetryCommonPropertiesShouldContainEmptyLibcReleaseAndVersion2 ( )
149
149
{
150
150
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
151
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Release" ] . Should ( ) . BeEmpty ( ) ;
152
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Version" ] . Should ( ) . BeEmpty ( ) ;
151
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Release" ] . Should ( ) . BeEmpty ( ) ;
152
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Version" ] . Should ( ) . BeEmpty ( ) ;
153
153
}
154
154
155
155
[ LinuxOnlyFact ]
@@ -158,8 +158,8 @@ public void TelemetryCommonPropertiesShouldContainLibcReleaseAndVersion()
158
158
if ( ! RuntimeInformation . RuntimeIdentifier . Contains ( "alpine" , StringComparison . OrdinalIgnoreCase ) )
159
159
{
160
160
var unitUnderTest = new TelemetryCommonProperties ( getMACAddress : ( ) => null , userLevelCacheWriter : new NothingCache ( ) ) ;
161
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Release" ] . Should ( ) . NotBeEmpty ( ) ;
162
- unitUnderTest . GetTelemetryCommonProperties ( ) [ "Libc Version" ] . Should ( ) . NotBeEmpty ( ) ;
161
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Release" ] . Should ( ) . NotBeEmpty ( ) ;
162
+ unitUnderTest . GetTelemetryCommonProperties ( "dummySessionId" ) [ "Libc Version" ] . Should ( ) . NotBeEmpty ( ) ;
163
163
}
164
164
}
165
165
@@ -184,6 +184,18 @@ public void CanDetectCIStatusForEnvVars(Dictionary<string, string> envVars, bool
184
184
}
185
185
}
186
186
187
+ [ Theory ]
188
+ [ InlineData ( "dummySessionId" ) ]
189
+ [ InlineData ( null ) ]
190
+ public void TelemetryCommonPropertiesShouldContainSessionId ( string sessionId )
191
+ {
192
+ var unitUnderTest = new TelemetryCommonProperties ( userLevelCacheWriter : new NothingCache ( ) ) ;
193
+ var commonProperties = unitUnderTest . GetTelemetryCommonProperties ( sessionId ) ;
194
+
195
+ commonProperties . Should ( ) . ContainKey ( "SessionId" ) ;
196
+ commonProperties [ "SessionId" ] . Should ( ) . Be ( sessionId ) ;
197
+ }
198
+
187
199
public static IEnumerable < object [ ] > CITelemetryTestCases => new List < object [ ] > {
188
200
new object [ ] { new Dictionary < string , string > { { "TF_BUILD" , "true" } } , true } ,
189
201
new object [ ] { new Dictionary < string , string > { { "GITHUB_ACTIONS" , "true" } } , true } ,
0 commit comments