Пример #1
0
        public void Seed64OpensUnused()
        {
            var seed = new SeedU64(999);

            Assert.AreEqual(1000, seed.Increment());

            seed.Open(500);

            Assert.AreEqual(500, seed.Peek());

            Assert.AreEqual(500, seed.Increment());

            Assert.AreEqual(1000, seed.LastSeed);
        }
Пример #2
0
        public void Seed64IsThreadSafe()
        {
            var seed = new SeedU64(999);

            var ids = new List<ulong>();

            seed.Open(20000);

            Parallel.For(0, 50, delegate(int i)
            {
                ids.Add(seed.Increment());
            });

            Assert.AreEqual(50, ids.Distinct().Count());

            Assert.AreEqual(1050, seed.Increment());

            Assert.AreEqual(1050, seed.LastSeed);
        }