Example #1
0
        public void CreateMultipleSame()
        {
            // preparation
            var dic = Dictionary;

            dic.Clear();
            Assert.AreEqual(0, dic.Count);

            var lockItems = new List <UuidLock>();

            // action
            for (var i = 1; i < 256; i++)
            {
                // create
                var l = new UuidLock($"UUID_{i}");
                lockItems.Add(l);
                // Assert
                Assert.AreEqual(i, dic.Count);
            }
            // Assert
            Assert.AreEqual(255, dic.Count);

            foreach (var lockItem in lockItems.ToArray())
            {
                // dispose
                lockItem.Dispose();
                lockItems.Remove(lockItem);
                // Assert
                Assert.AreEqual(lockItems.Count, dic.Count);
            }

            // Assert
            Assert.AreEqual(0, dic.Count);
        }
Example #2
0
        public void CreateMethod(string uuid)
        {
            // preparation
            var dic = Dictionary;

            dic.Clear();
            // action
            using (var l = new UuidLock(uuid)) { }
        }
Example #3
0
        public void CreateMethodThrowException()
        {
            // preparation
            var dic = Dictionary;

            dic.Clear();
            // action
            Assert.ThrowsException <ArgumentNullException>(() =>
            {
                using (var l = new UuidLock(null)) { }
            });
        }
Example #4
0
        public void CreateMultiple()
        {
            // preparation
            var dic = Dictionary;

            dic.Clear();
            Assert.AreEqual(0, dic.Count);

            // action
            for (var i = 0; i < 256; i++)
            {
                // create
                using (var l = new UuidLock($"UUID_{i}"))
                {
                    // Assert
                    Assert.AreEqual(1, dic.Count);
                }
                // Assert
                Assert.AreEqual(0, dic.Count);
            }
            // Assert
            Assert.AreEqual(0, dic.Count);
        }