コード例 #1
0
        public void ShouldThrowArgumentOutOfRangeExceptionWhenLampOnCountIsGreaterThenLampCount([Random(0, 5, 1)] int lampCount, [Random(6, 10, 1)] int lampOnCount)
        {
            //GIVEN
            var lampRowValidator = new LampRowValidator(lampCount);

            //THEN
            Assert.Throws <ArgumentOutOfRangeException>(() => lampRowValidator.Validate(lampOnCount));
        }
コード例 #2
0
        public void ShouldNotThrowArgumentOutOfRangeExceptionWhenLampOnCountIsLowerOrEqualLampCount([Random(5, 10, 1)] int lampCount, [Random(0, 5, 1)] int lampOnCount)
        {
            //GIVEN
            var lampRowValidator = new LampRowValidator(lampCount);

            //THEN
            Assert.DoesNotThrow(() => lampRowValidator.Validate(lampOnCount));
        }
コード例 #3
0
        public string Parse(int lampOnCount)
        {
            _lampRowValidator.Validate(lampOnCount);

            var row = new StringBuilder(_lampCount);

            for (var i = 1; i <= lampOnCount; i++)
            {
                row.Append((char)LampSelector().Invoke(i));
            }

            return(row.ToString().PadRight(_lampCount, (char)LampState.Off));
        }