コード例 #1
0
ファイル: TestIdentifierManager.cs プロジェクト: zzy092/npoi
        public void TestBasic()
        {
            IdentifierManager manager = new IdentifierManager(0L, 100L);

            Assert.AreEqual(101L, manager.GetRemainingIdentifiers());
            Assert.AreEqual(0L, manager.ReserveNew());
            Assert.AreEqual(100L, manager.GetRemainingIdentifiers());
            Assert.AreEqual(1L, manager.Reserve(0L));
            Assert.AreEqual(99L, manager.GetRemainingIdentifiers());
        }
コード例 #2
0
ファイル: TestIdentifierManager.cs プロジェクト: zzy092/npoi
        public void TestLongLimits()
        {
            long min = IdentifierManager.MIN_ID;
            long max = IdentifierManager.MAX_ID;
            IdentifierManager manager = new IdentifierManager(min, max);

            Assert.IsTrue(max - min + 1 > 0, "Limits lead to a long variable overflow");
            Assert.IsTrue(manager.GetRemainingIdentifiers() > 0, "Limits lead to a long variable overflow");
            Assert.AreEqual(min, manager.ReserveNew());
            Assert.AreEqual(max, manager.Reserve(max));
            Assert.AreEqual(max - min - 1, manager.GetRemainingIdentifiers());
            manager.Release(max);
            manager.Release(min);
        }