Exemple #1
0
        public void UserSuppliedSource_IsWhatIsSupplied()
        {
            var initial = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            var source  = new UserSuppliedSource(initial);
            var result  = source.GetEntropyAsync(EntropyPriority.Normal).GetAwaiter().GetResult();

            CollectionAssert.AreEqual(result, initial);
            // Second call should have cleared the stored entropy.
            var result2 = source.GetEntropyAsync(EntropyPriority.Normal).GetAwaiter().GetResult();

            Assert.IsNull(result2);
        }
Exemple #2
0
        public void UserSuppliedSource_SetEntropy()
        {
            var initial = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            var source  = new UserSuppliedSource(initial);
            var result  = source.GetEntropyAsync(EntropyPriority.Normal).GetAwaiter().GetResult();

            CollectionAssert.AreEqual(result, initial);

            var updated = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 };

            source.SetEntropy(updated);
            var result2 = source.GetEntropyAsync(EntropyPriority.Normal).GetAwaiter().GetResult();

            CollectionAssert.AreEqual(result2, updated);

            // After a call the entropy should be cleared.
            var result3 = source.GetEntropyAsync(EntropyPriority.Normal).GetAwaiter().GetResult();

            Assert.IsNull(result3);
        }