コード例 #1
0
        public void ResolveTie_SplitsTheResultsApproximatelyByExpectation()
        {
            // Arrange
            var tieBreaker = new RandomisingTwoWayTieBreaker(0.3);

            // Act
            var leftResultCount = 0;
            var rightResultCount = 0;
            for (var i = 0; i < 10000; i++)
            {
                switch (tieBreaker.ResolveTie())
                {
                    case TieResult.Left:
                        leftResultCount++;
                        break;
                    case TieResult.Right:
                        rightResultCount++;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            // Assert
            leftResultCount.Should().BeLessThan(4000).And.BeGreaterThan(2000);
            rightResultCount.Should().BeLessThan(8000).And.BeGreaterThan(6000);
        }
コード例 #2
0
        public void GivenLeftProbability_CreatesATieBreakerWithThatLeftProbability()
        {
            // Act
            const double leftProbability = 0.643;
            var tieBreaker = new RandomisingTwoWayTieBreaker(leftProbability);

            // Assert
            tieBreaker.LeftProbability.Should().Be(leftProbability);
            tieBreaker.RightProbability.Should().Be(1 - leftProbability);
        }