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


            haw.Dispose();
        }
コード例 #2
0
        public void HashAlgorithmWrapper_Dispose_NonOwner_Preserves_HashAlgorithm()
        {
            var ha = new SHA1Managed();
            var haw = new HashAlgorithmWrapper(ha, false);


            haw.Dispose();


            // HashAlgorithm should still be usable.
            ha.ComputeHash(new byte[0]);
            ha.ComputeHash(new MemoryStream());


            // HashAlgorithmWrapper's usability afterwards is an implementation detail 
            //   and shouldn't be tested.
        }
コード例 #3
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()));
        }
コード例 #4
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()));
        }
コード例 #5
0
        public void HashAlgorithmWrapper_Generic_Dispose_DoesNotThrow()
        {
            var haw = new HashAlgorithmWrapper<SHA1Managed>();

            haw.Dispose();
        }