Ejemplo n.º 1
0
        public void Sample(String inputSample, Int32 expectedOutputSample)
        {
            var inputDistribution = new MockDistribution <String>(inputSample);

            var outputDistribution = inputDistribution.Select(x => x.Length);

            // Use a throwing RNG to check that sampling from the distribution
            // does not update the state of the RNG directly.
            var rng = new ThrowingRng();

            var sampleFromOutputDistribution = outputDistribution.Sample(rng);

            Assert.Equal(expectedOutputSample, sampleFromOutputDistribution);
        }
Ejemplo n.º 2
0
        public void TrySample(
            String inputResult,
            Boolean inputSuccess,
            Int32 expectedOutputResult,
            Boolean expectedOutputSuccess)
        {
            var inputDistribution = new MockDistribution <String>(inputResult, inputSuccess);

            var outputDistribution = inputDistribution.Select(x => x.Length);

            // Use a throwing RNG to check that sampling from the distribution
            // does not update the state of the RNG directly.
            var rng = new ThrowingRng();

            Assert.Equal(expectedOutputSuccess, outputDistribution.TrySample(rng, out var result));
            Assert.Equal(expectedOutputResult, result);
        }