public void TryCreateId_Returns_False_OnClockBackwards() { var ts = new MockTimeSource(100); var g = new IdGenerator(0, new IdGeneratorOptions(timeSource: ts)); Assert.IsTrue(g.TryCreateId(out var _)); ts.PreviousTick(); // Set clock back 1 'tick', this results in the time going from "100" to "99" Assert.IsFalse(g.TryCreateId(out var _)); }
public void CreateId_Throws_OnClockBackwards() { var ts = new MockTimeSource(100); var g = new IdGenerator(0, new IdGeneratorOptions(timeSource: ts)); g.CreateId(); ts.PreviousTick(); // Set clock back 1 'tick', this results in the time going from "100" to "99" g.CreateId(); }
public void CreateId_Throws_OnClockBackwards() { var ts = new MockTimeSource(DateTime.UtcNow); var m = MaskConfig.Default; var g = new IdGenerator(0, TESTEPOCH, m, ts); g.CreateId(); ts.PreviousTick(); //Set clock back 1 'tick' (ms) g.CreateId(); }
public void CreateId_Throws_OnClockBackwards() { var ts = new MockTimeSource(100); var m = MaskConfig.Default; var g = new IdGenerator(0, TESTEPOCH, m, ts); g.CreateId(); ts.PreviousTick(); // Set clock back 1 'tick', this results in the time going from "100" to "99" g.CreateId(); }