@@ -27,17 +27,36 @@ final class VMConfigFileTests: XCTestCase {
2727 }
2828
2929 func testThatHardwareModelIsParsedCorrectly( ) throws {
30- XCTAssert (
31- try configFileSample1. hardwareModel. dataRepresentation,
32- hasHash: " 3aTbdKrJ+27C8JaCzSmHNr32t5IbeuA5VjC48XCcGu8= "
33- )
30+ let dataRep = try configFileSample1. hardwareModel. dataRepresentation
31+ // The `dataRepresentation` is supposed to be an opaque value / implementation detail,
32+ // but that's the only property we have access to and we can thus use for testing correct parsing.
33+ //
34+ // This `dataRepresentation` happens to be a binary plist representation of a NSDictionary.
35+ // We can't just compare the `dataRepresentation` directly with a fixed value though, because different
36+ // versions of macOS might serialize the exact same NSDictionary as a slightly different NSData representation.
37+ // Besides, future macOS versions might add additional keys in that internal representation of those objects.
38+ //
39+ // So the best we can do is check that the `dataRepresentation` is not nil and check some keys in that dict.
40+ // This is a bit fragile but at least it's more resilient than comparing the `dataRepresentation` directly.
41+ let dictRep = try XCTUnwrap ( PropertyListSerialization . propertyList ( from: dataRep, format: nil ) as? NSDictionary )
42+ XCTAssertEqual ( dictRep [ " MinimumSupportedOS " ] as? NSArray , [ 13 , 0 , 0 ] )
43+ XCTAssertEqual ( dictRep [ " PlatformVersion " ] as? NSNumber , 2 )
3444 }
3545
3646 func testThatMachineIdentifierIsParsedCorrectly( ) throws {
37- XCTAssert (
38- try configFileSample1. machineIdentifier. dataRepresentation,
39- hasHash: " 0DXW7UIFta6W86ZZd24QUy4Gx3EX1+r9i+yYk7xHi0s= "
40- )
47+ let dataRep = try configFileSample1. machineIdentifier. dataRepresentation
48+ // The `dataRepresentation` is supposed to be an opaque value / implementation detail,
49+ // but that's the only property we have access to and we can thus use for testing correct parsing.
50+ //
51+ // This `dataRepresentation` happens to be a binary plist representation of a NSDictionary.
52+ // We can't just compare the `dataRepresentation` directly with a fixed value though, because different
53+ // versions of macOS might serialize the exact same NSDictionary as a slightly different NSData representation.
54+ // Besides, future macOS versions might add additional keys in that internal representation of those objects.
55+ //
56+ // So the best we can do is check that the `dataRepresentation` is not nil and check some keys in that dict.
57+ // This is a bit fragile but at least it's more resilient than comparing the `dataRepresentation` directly.
58+ let dictRep = try XCTUnwrap ( PropertyListSerialization . propertyList ( from: dataRep, format: nil ) as? NSDictionary )
59+ XCTAssertNotNil ( dictRep [ " ECID " ] )
4160 }
4261
4362 func testThatMacAddressIsParsedCorrectly( ) throws {
0 commit comments