Пример #1
0
        public void ChangingSingletonTest()
        {
            var di = DI.Default.New();

            var basis = new MersenneTwister();

            di.For <Random>().UseSingleton(basis);

            var rng = di.Get <Random>();

            Assert.AreEqual(rng, basis);

            var basis2 = new CryptoRandomNumbers();

            di.For <Random>().UseSingleton(basis2);

            var rng2 = di.Get <Random>();

            Assert.AreEqual(rng2, basis2);
            Assert.AreNotEqual(rng2, rng);
        }
Пример #2
0
 public void CryptoDisposeTest()
 {
     using (var rng = new CryptoRandomNumbers())
         Assert.AreNotEqual(int.MaxValue, rng.Next());
 }