@@ -60,11 +60,11 @@ public static void Test01Create()
60
60
Assert . False ( j . Environment . Gc . AllowVeryLargeObjects ) ;
61
61
Assert . Equal ( Platform . AnyCpu , j . Environment . Platform ) ;
62
62
Assert . Equal ( RunStrategy . Throughput , j . Run . RunStrategy ) ; // set by default
63
- Assert . Equal ( "Default " , j . Id ) ; // id reset
64
- Assert . True ( j . DisplayInfo == "DefaultJob" , "DisplayInfo = " + j . DisplayInfo ) ;
65
- Assert . True ( j . ResolvedId == "DefaultJob" , "ResolvedId = " + j . ResolvedId ) ;
63
+ Assert . Equal ( "CustomId " , j . Id ) ; // id remains after unfreeze
64
+ Assert . Equal ( "CustomId" , j . DisplayInfo ) ;
65
+ Assert . Equal ( "CustomId" , j . ResolvedId ) ;
66
66
Assert . Equal ( j . ResolvedId , j . FolderInfo ) ;
67
- Assert . Equal ( "Default " , j . Environment . Id ) ;
67
+ Assert . Equal ( "CustomId " , j . Environment . Id ) ; // id remains after unfreeze
68
68
69
69
// new job
70
70
j = new Job ( j . Freeze ( ) ) ;
@@ -160,7 +160,7 @@ public static void Test02Modify()
160
160
// 4. Freeze-unfreeze:
161
161
j = j . Freeze ( ) . UnfreezeCopy ( ) ;
162
162
163
- Assert . Equal ( "Platform=X86, LaunchCount=1 " , j . Id ) ;
163
+ Assert . Equal ( "SomeId " , j . Id ) ; // id not lost
164
164
Assert . Equal ( Platform . X86 , j . Environment . Platform ) ;
165
165
Assert . Equal ( 1 , j . Run . LaunchCount ) ;
166
166
@@ -204,15 +204,15 @@ public static void Test03IdDoesNotFlow()
204
204
Assert . False ( j . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
205
205
Assert . False ( j . Environment . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
206
206
207
- Job . EnvironmentCharacteristic [ j ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ; // id will not flow
208
- Assert . False ( j . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
209
- Assert . False ( j . Environment . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
207
+ Job . EnvironmentCharacteristic [ j ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ; // id will flow
208
+ Assert . True ( j . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
209
+ Assert . True ( j . Environment . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
210
210
211
211
var c = new CharacteristicSet ( EnvironmentMode . LegacyJitX64 , RunMode . Long ) ; // id will not flow, new CharacteristicSet
212
212
Assert . False ( c . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
213
213
214
- Job . EnvironmentCharacteristic [ c ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ; // id will not flow
215
- Assert . False ( c . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
214
+ Job . EnvironmentCharacteristic [ c ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ; // id will flow
215
+ Assert . True ( c . HasValue ( CharacteristicObject . IdCharacteristic ) ) ;
216
216
217
217
CharacteristicObject . IdCharacteristic [ c ] = "MyId" ; // id set explicitly
218
218
Assert . Equal ( "MyId" , c . Id ) ;
@@ -221,12 +221,12 @@ public static void Test03IdDoesNotFlow()
221
221
Assert . Equal ( "MyId" , j . Id ) ;
222
222
Assert . Equal ( "MyId" , j . Environment . Id ) ;
223
223
224
- Job . EnvironmentCharacteristic [ j ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ; // id will not flow
225
- Assert . Equal ( "MyId " , j . Id ) ;
226
- Assert . Equal ( "MyId " , j . Environment . Id ) ;
224
+ Job . EnvironmentCharacteristic [ j ] = EnvironmentMode . LegacyJitX86 . UnfreezeCopy ( ) ;
225
+ Assert . Equal ( "LegacyJitX86 " , j . Id ) ;
226
+ Assert . Equal ( "LegacyJitX86 " , j . Environment . Id ) ;
227
227
228
- j = j . WithJit ( Jit . RyuJit ) ; // custom id will flow
229
- Assert . Equal ( "MyId " , j . Id ) ;
228
+ j = j . WithJit ( Jit . RyuJit ) ;
229
+ Assert . Equal ( "LegacyJitX86 " , j . Id ) ;
230
230
}
231
231
232
232
[ Fact ]
@@ -474,6 +474,20 @@ public static void WithNuGet()
474
474
Assert . Equal ( expected , j . Infrastructure . NuGetReferences ) ; // ensure that the list's equality operator returns true when the contents are the same
475
475
}
476
476
477
+ [ Fact ]
478
+ public static void UnfreezeCopy_PreservesIdCharacteristic ( )
479
+ {
480
+ // Arrange
481
+ var original = new Job ( ) ;
482
+ original . SetValue ( Job . IdCharacteristic , "TestID" ) ;
483
+
484
+ // Act
485
+ var copy = original . UnfreezeCopy ( ) ;
486
+
487
+ // Assert
488
+ Assert . Equal ( "TestID" , copy . GetValue ( Job . IdCharacteristic ) ) ;
489
+ }
490
+
477
491
private static bool IsSubclassOfobModeOfItself ( Type type )
478
492
{
479
493
Type jobModeOfT ;
0 commit comments