public void ParseTimeSpan_WithStandardTimeSpanString_ParsesTimeSpan()
        {
            var expected = new TimeSpan(12, 15, 10);
            var input    = "12:15:10";

            var converter = new TimeSpanConverter();
            var actual    = converter.ConvertFromInvariantString(input);

            Assert.AreEqual(expected, actual);
        }
        public void ParseTimeSpan_WithTimeSpanNoFormatString_ParsesTimeSpan()
        {
            var expected = new TimeSpan(0, 0, 12);
            var input    = "12";

            var converter = new TimeSpanConverter();
            var actual    = converter.ConvertFromInvariantString(input);

            Assert.AreEqual(expected, actual);
        }
        public void ConvertTimeSpan_WithNegativeTimeSpanSecondsInput_ParsesTimeSpan()
        {
            var          expected = new TimeSpan(0, 0, -12);
            const string input    = "-12s";

            var converter = new TimeSpanConverter();
            var actual    = converter.ConvertFromInvariantString(input);

            Assert.AreEqual(expected, actual);
        }
示例#4
0
        } // OncheduleKindChanged

        private void InitComboQuickSettings(ComboBox combo)
        {
            TimeSpanConverter converter;

            string[] linesSeparators;
            string[] lineSeparators;
            string[] lines;

            combo.DisplayMember = "Key";
            combo.ValueMember   = "Value";
            converter           = new TimeSpanConverter();
            linesSeparators     = new string[] { "\r\n" };
            lineSeparators      = new string[] { " ~ " };
            lines = ControlTexts.RecordTimeQuickSettings.Split(linesSeparators, StringSplitOptions.RemoveEmptyEntries);
            foreach (var line in lines)
            {
                var parts = line.Split(lineSeparators, StringSplitOptions.RemoveEmptyEntries);
                combo.Items.Add(new KeyValuePair <string, TimeSpan>(key: parts[0],
                                                                    value: (TimeSpan)converter.ConvertFromInvariantString(parts[1])));
            } // foreach line
        }     // InitComboQuickSettings