public void ParseInputString_ValidFormats(string input, int expectedHours, int expectedMinutes, int expectedSeconds)
        {
            var parser = new ColonSeparatedParser();
            var time   = parser.ParseInputString(input);

            Assert.AreEqual(expectedHours, time.Hours);
            Assert.AreEqual(expectedMinutes, time.Minutes);
            Assert.AreEqual(expectedSeconds, time.Seconds);
        }
Example #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());
        }
        public void ParseInputString_InvalidFormats(string input)
        {
            var parser = new ColonSeparatedParser();

            Assert.Throws <ArgumentException>(() => parser.ParseInputString(input));
        }