public void SampledIdentifiersAreBetween0And1(int numSamples) { var checkpointTime = DateTime.UtcNow; for (var i = 0; i < numSamples; ++i) { var sample = RestoreCheckpointPacemaker.SampleIdentifier(ThreadSafeRandom.GetBytes(10), checkpointTime); sample.Should().BeInRange(0, 1); } }
public void SampledIdentifiersDontChangeUnlessCheckpointTimeDoes(int numSamples) { for (var i = 0; i < numSamples; ++i) { var checkpointTime = DateTime.UtcNow; var machine = ThreadSafeRandom.GetBytes(10); var sample1 = RestoreCheckpointPacemaker.SampleIdentifier(machine, checkpointTime); var sample2 = RestoreCheckpointPacemaker.SampleIdentifier(machine, checkpointTime); sample1.Should().Be(sample2); var checkpointTime2 = checkpointTime + TimeSpan.FromSeconds(1); var sample3 = RestoreCheckpointPacemaker.SampleIdentifier(machine, checkpointTime2); var sample4 = RestoreCheckpointPacemaker.SampleIdentifier(machine, checkpointTime2); sample1.Should().NotBe(sample3); sample3.Should().Be(sample4); } }