コード例 #1
0
        public void TestReserveNew()
        {
            IdentifierManager manager = new IdentifierManager(10L, 12L);

            Assert.AreEqual(10L, manager.ReserveNew());
            Assert.AreEqual(11L, manager.ReserveNew());
            Assert.AreEqual(12L, manager.ReserveNew());
            try
            {
                manager.ReserveNew();
                Assert.Fail("InvalidOperationException expected");
            }
            catch (InvalidOperationException)
            {
                // expected
            }
        }
コード例 #2
0
ファイル: TestIdentifierManager.cs プロジェクト: 89sos98/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());
 }
コード例 #3
0
        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());
        }
コード例 #4
0
ファイル: TestIdentifierManager.cs プロジェクト: 89sos98/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);
 }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: TestIdentifierManager.cs プロジェクト: 89sos98/npoi
 public void TestReserveNew()
 {
     IdentifierManager manager = new IdentifierManager(10L, 12L);
     Assert.AreEqual(10L, manager.ReserveNew());
     Assert.AreEqual(11L, manager.ReserveNew());
     Assert.AreEqual(12L, manager.ReserveNew());
     try
     {
         manager.ReserveNew();
         Assert.Fail("InvalidOperationException expected");
     }
     catch (InvalidOperationException)
     {
         // expected
     }
 }