public void If_sample_rate_is_0_5_then_have_half_true() { var numberOfTrues = 0; for (var i = 0; i < NumberOfTestsToRun; i++) { if (SamplerDefault.ShouldSend(0.5)) { numberOfTrues++; } } Assert.That(Math.Round(numberOfTrues / (double)NumberOfTestsToRun, 1), Is.EqualTo(0.5)); }
public void If_sample_rate_is_one_tenth_of_pct_then_have_one_tenth_of_pct() { var numberOfTrues = 0; const int sampleRate = 1 / 1000; for (var i = 0; i < NumberOfTestsToRun; i++) { if (SamplerDefault.ShouldSend(sampleRate)) { numberOfTrues++; } } Assert.That(Math.Round(numberOfTrues / (double)NumberOfTestsToRun, 1), Is.EqualTo(sampleRate)); }