public void HashFullArrayInvalidArguments() { using (HashAlgorithm hash = new Length32Hash()) { Assert.Throws <ArgumentNullException>(() => hash.ComputeHash((byte[])null)); hash.Dispose(); Assert.Throws <ObjectDisposedException>(() => hash.ComputeHash(s_tenBytes)); } }
public void StreamHashInvalidArguments() { using (var stream = new PositionValueStream(0)) using (HashAlgorithm hash = new Length32Hash()) { Assert.Throws <NullReferenceException>(() => hash.ComputeHash((Stream)null)); hash.Dispose(); Assert.Throws <ObjectDisposedException>(() => hash.ComputeHash(stream)); } }
public void HashPartialArrayInvalidArguments() { using (HashAlgorithm hash = new Length32Hash()) { Assert.Throws <ArgumentNullException>(() => hash.ComputeHash((byte[])null, 0, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => hash.ComputeHash(s_tenBytes, -1, 0)); AssertExtensions.Throws <ArgumentException>(null, () => hash.ComputeHash(s_tenBytes, 0, -1)); AssertExtensions.Throws <ArgumentException>(null, () => hash.ComputeHash(s_tenBytes, 0, 11)); AssertExtensions.Throws <ArgumentException>(null, () => hash.ComputeHash(s_tenBytes, 9, 2)); hash.Dispose(); Assert.Throws <ObjectDisposedException>(() => hash.ComputeHash(s_tenBytes, 0, 10)); } }