(CW, because it is too important for comment)
This test will be repeated only when Random is selected. You should publish the code that calls the dictionary, because there might be something suspicious (provided that the code is sent - this is the actual code) or even better to post your own test that reproduces the problem.
[Test] public void TestDictionary() { var dictionary = new Dictionary(); for(int i = 0; i < 10; i++) { Console.WriteLine(dictionary.GetNext()); } } [Serializable]
This test repeats your results, but because of the answer here :
[Test] public void TestDictionary2() { var alpha = new Dictionary(); var bravo = new Dictionary(); for(int i = 0; i < 10; i++) { Console.WriteLine("{0} - {1}", alpha.GetNext(), bravo.GetNext()); } }
For completeness, serialization testing has been done here:
[Test] public void SerializationPerhaps() { var charlie = new Dictionary(); Dictionary delta = null; // Borrowed from MSDN: http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx //Opens a file and serializes the object into it in binary format. using (var stream = File.Open("data.xml", FileMode.Create)) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, charlie); } //Opens file "data.xml" and deserializes the object from it. using (var stream = File.Open("data.xml", FileMode.Open)) { var formatter = new BinaryFormatter(); delta = (Dictionary) formatter.Deserialize(stream); stream.Close(); } for(int i = 0; i < 10; i++) { Assert.AreEqual(charlie.GetNext(), delta.GetNext()); } }
Austin salonen
source share