public void SetKeyNull() { using (var keyedHash = new TestKeyedHashAlgorithm()) { Assert.Throws<NullReferenceException>(() => keyedHash.Key = null); } }
public void SetKeyNull() { using (var keyedHash = new TestKeyedHashAlgorithm()) { Assert.Throws <NullReferenceException>(() => keyedHash.Key = null); } }
public void SetKeyNull() { using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = new byte[1]; Assert.NotNull(keyedHash.Key); keyedHash.Key = null; Assert.Null(keyedHash.Key); } }
public void EnsureDisposeFreesKey() { byte[] key = new[] { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, }; using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = key; Assert.NotNull(keyedHash.Key); keyedHash.Dispose(); Assert.Null(keyedHash.Key); } }
public void EnsureDisposeFreesKey() { byte[] key = new[] { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, }; using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = key; Assert.NotNull(keyedHash.Key); keyedHash.Dispose(); byte[] ignored; Assert.Throws<NullReferenceException>(() => ignored = keyedHash.Key); } }
public void EnsureDisposeFreesKey() { byte[] key = new[] { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, }; using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = key; Assert.NotNull(keyedHash.Key); keyedHash.Dispose(); byte[] ignored; Assert.Throws <NullReferenceException>(() => ignored = keyedHash.Key); } }
public void EnsureKeyIsolation() { byte[] key = new[] { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, }; byte[] keyCopy = (byte[])key.Clone(); using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = key; key[0]++; byte[] hashKey = keyedHash.Key; Assert.Equal(keyCopy, hashKey); Assert.NotEqual(key, hashKey); } }
public void EnsureGetKeyCopies() { byte[] key = new[] { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, }; using (var keyedHash = new TestKeyedHashAlgorithm()) { keyedHash.Key = key; byte[] getKey1 = keyedHash.Key; byte[] getKey2 = keyedHash.Key; Assert.NotSame(getKey1, getKey2); Assert.Equal(getKey1, getKey2); Assert.Equal(key, getKey1); getKey1[0]++; Assert.NotEqual(getKey1, getKey2); } }