Пример #1
0
        static public void TestSAMStoreKeys()
        {
            string mach1  = "machine1";
            string mach1a = "machine1";
            string mach2  = "machine2";

            byte[] sid1a = new byte[] { 0x1, 0x2, 0x3 };
            byte[] sid1b = new byte[] { 0x1, 0x2, 0x3 };
            byte[] sid2  = new byte[] { 0x10, 0x20, 0x30 };

            SAMStoreKey key1a = new SAMStoreKey(mach1, sid1a);
            SAMStoreKey key1b = new SAMStoreKey(mach1, sid1a);
            SAMStoreKey key1c = new SAMStoreKey(mach1a, sid1b);
            SAMStoreKey key2  = new SAMStoreKey(mach2, sid2);
            SAMStoreKey key3  = new SAMStoreKey(mach1, sid2);

            Debug.Assert(key1a.Equals(key1b));
            Debug.Assert(key1a.Equals(key1c));

            Debug.Assert(!key1a.Equals(key2));
            Debug.Assert(!key1a.Equals(key3));

            Debug.Assert(key1a.GetHashCode() != key2.GetHashCode());

            // Shouldn't matter, since SAMStoreKey should make a copy of the byte[] sid
            sid1b[1] = 0xf;
            Debug.Assert(key1a.Equals(key1b));
            Debug.Assert(key1a.Equals(key1c));
        }