@@ -45,8 +45,14 @@ public void TestCaseObjectShouldSerializeCustomProperties()
4545 var json = Serialize ( test ) ;
4646
4747 // Use raw deserialization to validate basic properties
48- var expectedJson = "{\" Properties\" :[{\" Key\" :{\" Id\" :\" 1\" ,\" Label\" :\" label1\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Guid\" },\" Value\" :\" 02048dfd-3da7-475d-a011-8dd1121855ec\" },{\" Key\" :{\" Id\" :\" 2\" ,\" Label\" :\" label2\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Int32\" },\" Value\" :29}]}" ;
49- Assert . AreEqual ( expectedJson , json ) ;
48+ // Because properties are backed up by a ConcurrentDictionary we don't have control over the order of serialization
49+ var expectedJsonWithKey1First = "{\" Properties\" :[{\" Key\" :{\" Id\" :\" 1\" ,\" Label\" :\" label1\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Guid\" },\" Value\" :\" 02048dfd-3da7-475d-a011-8dd1121855ec\" },{\" Key\" :{\" Id\" :\" 2\" ,\" Label\" :\" label2\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Int32\" },\" Value\" :29}]}" ;
50+ var expectedJsonWithKey2First = "{\" Properties\" :[{\" Key\" :{\" Id\" :\" 2\" ,\" Label\" :\" label2\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Int32\" },\" Value\" :29},{\" Key\" :{\" Id\" :\" 1\" ,\" Label\" :\" label1\" ,\" Category\" :\" \" ,\" Description\" :\" \" ,\" Attributes\" :0,\" ValueType\" :\" System.Guid\" },\" Value\" :\" 02048dfd-3da7-475d-a011-8dd1121855ec\" }]}" ;
51+
52+ if ( json != expectedJsonWithKey1First && json != expectedJsonWithKey2First )
53+ {
54+ Assert . Fail ( $ "Was expecting <{ json } > to be either <{ expectedJsonWithKey1First } > or <{ expectedJsonWithKey2First } >.") ;
55+ }
5056 }
5157
5258 [ TestMethod ]
@@ -86,8 +92,8 @@ public void TestObjectShouldDeserializeCustomProperties()
8692
8793 var properties = test . Properties . ToArray ( ) ;
8894 Assert . AreEqual ( 2 , properties . Length ) ;
89- Assert . AreEqual ( Guid . Parse ( "02048dfd-3da7-475d-a011-8dd1121855ec" ) , test . GetPropertyValue ( properties [ 0 ] ) ) ;
90- Assert . AreEqual ( 29 , test . GetPropertyValue ( properties [ 1 ] ) ) ;
95+ Assert . AreEqual ( Guid . Parse ( "02048dfd-3da7-475d-a011-8dd1121855ec" ) , test . GetPropertyValue ( properties . First ( x => x . Label == "label1" ) ) ) ;
96+ Assert . AreEqual ( 29 , test . GetPropertyValue ( properties . First ( x => x . Label == "label2" ) ) ) ;
9197 }
9298
9399 [ TestMethod ]
0 commit comments