コード例 #1
0
 public LogMessageRouter(int skipPercentage)
 {
     if (skipPercentage > 0)
     {
         _logDice = new WinLoseDice(skipPercentage);
     }
 }
コード例 #2
0
ファイル: when_rolling.cs プロジェクト: kbabiy/LogCast
 public void then_100_fail_rate_always_lose()
 {
     _sut = new WinLoseDice(100);
     for (int i = 0; i < 100; i++)
     {
         _sut.Roll().Should().BeFalse();
     }
 }
コード例 #3
0
ファイル: when_rolling.cs プロジェクト: kbabiy/LogCast
 public void then_0_fail_rate_always_wins()
 {
     _sut = new WinLoseDice(0);
     for (int i = 0; i < 100; i++)
     {
         _sut.Roll().Should().BeTrue();
     }
 }
コード例 #4
0
ファイル: when_rolling.cs プロジェクト: kbabiy/LogCast
        private void RunDeviationTest(int numberOfRolls, int maxDeviation)
        {
            int failRate   = 30;
            int failsCount = 0;

            _sut = new WinLoseDice(failRate);
            for (int i = 0; i < numberOfRolls; i++)
            {
                if (!_sut.Roll())
                {
                    failsCount++;
                }
            }

            var deviation = Math.Abs(failRate - failsCount * 100 / (double)numberOfRolls);

            deviation.Should().BeLessOrEqualTo(maxDeviation);
        }
コード例 #5
0
        public int then_fail_rate_boundary_is_set_correctly(int failRate)
        {
            var sut = new WinLoseDice(failRate);

            return(sut.FailThreshold);
        }