示例#1
0
        public void GetFormatedString(int hours)
        {
            var timeHolder = new TimeHolder()
            {
                Hours   = hours,
                Minutes = 0,
                Seconds = 0,
            };

            var formatter = new HourFormatter(_redColorProvider);
            var result    = formatter.GetFormattedStringBlock(timeHolder);

            var lines = result.Split(new [] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            Assert.AreEqual(2, lines.Length);
            Assert.AreEqual(4, lines[0].Length);
            Assert.AreEqual(4, lines[1].Length);
        }
示例#2
0
        public string convertTime(string aTime)
        {
            if (string.IsNullOrEmpty(aTime))
            {
                throw new ArgumentNullException(nameof(aTime));
            }

            var timeHolder = _inputParser.ParseInputString(aTime);

            var sb      = new StringBuilder();
            var seconds = new SecondFormatter(_yellowProvider);

            sb.Append(seconds.GetFormattedStringBlock(timeHolder));

            var hours = new HourFormatter(_redProvider);

            sb.Append(hours.GetFormattedStringBlock(timeHolder));

            var minutes = new MinuteFormatter(_yellowProvider, _redProvider);

            sb.Append(minutes.GetFormattedStringBlock(timeHolder));

            return(sb.ToString().TrimEnd());
        }