コード例 #1
0
        public void HashAlgorithmWrapper_Dispose_Owner_Invalidates()
        {
            var ha = new SHA1Managed();
            var haw = new HashAlgorithmWrapper(ha, true);


            haw.Dispose();


            // HashAlgorithm shouldn't be usable anymore.
            Assert.Throws<ObjectDisposedException>(() =>
                ha.ComputeHash(new byte[0]));

            Assert.Throws<ObjectDisposedException>(() =>
                ha.ComputeHash(new MemoryStream()));


            // HashAlgorithmWrapper should not be usable anymore either.
            Assert.Throws<ObjectDisposedException>(() =>
                haw.ComputeHash(new byte[0]));

            Assert.Throws<ObjectDisposedException>(() =>
                haw.ComputeHash(new MemoryStream()));
        }
コード例 #2
0
        public void HashAlgorithmWrapper_Generic_Dispose_Invalidates()
        {
            var haw = new HashAlgorithmWrapper<SHA1Managed>();

            haw.Dispose();


            // HashAlgorithmWrapper should no longer be usable.
            Assert.Throws<ObjectDisposedException>(() =>
                haw.ComputeHash(new byte[0]));

            Assert.Throws<ObjectDisposedException>(() =>
                haw.ComputeHash(new MemoryStream()));
        }