public void LimitTest() { IdProvider provider = new IdProvider(0, 1, 5); Assert.AreEqual(0, provider.Next()); Assert.AreEqual(1, provider.Next()); Assert.AreEqual(2, provider.Next()); Assert.AreEqual(3, provider.Next()); Assert.AreEqual(4, provider.Next()); Assert.AreEqual(5, provider.Next()); Assert.Throws <ArgumentOutOfRangeException>(() => provider.Next()); provider.Remove(2); provider.Remove(3); Assert.DoesNotThrow(() => _ = provider.Next()); Assert.DoesNotThrow(() => _ = provider.Next()); Assert.Throws <ArgumentOutOfRangeException>(() => provider.Next()); }
public void IncrementTest() { IdProvider provider = new IdProvider(0, 5); Assert.AreEqual(0, provider.Next()); Assert.AreEqual(5, provider.Next()); Assert.AreEqual(10, provider.Next()); Assert.AreEqual(15, provider.Next()); Assert.AreEqual(20, provider.Next()); // should do nothing provider.Remove(1); Assert.AreEqual(25, provider.Next()); Assert.AreEqual(30, provider.Next()); provider.Remove(5); provider.Remove(25); Assert.AreEqual(5, provider.Next()); Assert.AreEqual(25, provider.Next()); Assert.AreEqual(35, provider.Next()); Assert.AreEqual(40, provider.Next()); }
public void SimpleNextRemoveTest() { IdProvider provider = new IdProvider(0); Assert.AreEqual(0, provider.Next()); Assert.AreEqual(1, provider.Next()); Assert.AreEqual(2, provider.Next()); Assert.AreEqual(3, provider.Next()); Assert.AreEqual(4, provider.Next()); provider.Remove(1); provider.Remove(3); Assert.AreEqual(1, provider.Next()); Assert.AreEqual(3, provider.Next()); Assert.AreEqual(5, provider.Next()); Assert.AreEqual(6, provider.Next()); Assert.AreEqual(7, provider.Next()); provider.Remove(5); provider.Remove(7); Assert.AreEqual(5, provider.Next()); Assert.AreEqual(7, provider.Next()); Assert.AreEqual(8, provider.Next()); Assert.AreEqual(9, provider.Next()); Assert.AreEqual(10, provider.Next()); }