Ejemplo n.º 1
0
        public void ReturnDash_WhenFormattingNullTime()
        {
            var sut = new GeneralTimeFormatter();

            var formattedTime = sut.Format(null);

            Assert.Equal(TimeFormatConstants.DASH, formattedTime);
        }
Ejemplo n.º 2
0
        public void ReturnDash_WhenFormattingNullTime()
        {
            var formatter = new GeneralTimeFormatter();

            var formatted = formatter.Format(null);

            Assert.AreEqual(TimeFormatConstants.DASH, formatted);
        }
Ejemplo n.º 3
0
        public void ReturnExpectedValues_WhenFormattingNullTimeAndDeterminedNullFormatsAreExpected(
            NullFormat nullFormat, string expectedConversion)
        {
            var sut = new GeneralTimeFormatter
            {
                NullFormat = nullFormat
            };

            var formattedTime = sut.Format(null);

            Assert.Equal(expectedConversion, formattedTime);
        }
Ejemplo n.º 4
0
        public void FormatsTimeCorrectly_WhenDeterminedAccuracyIsSupplied(string timespanText, TimeAccuracy accuracy, string expectedTime)
        {
            var sut = new GeneralTimeFormatter
            {
                DigitsFormat = DigitsFormat.SingleDigitMinutes,
                Accuracy     = accuracy
            };
            var time          = TimeSpan.Parse(timespanText);
            var formattedTime = sut.Format(time);

            Assert.Equal(expectedTime, formattedTime);
        }
Ejemplo n.º 5
0
        public void ReturnZeroWithCorrectAmountOfDecimals_WhenZeroWithAccuracyIsExpected(
            NullFormat nullFormat, TimeAccuracy accuracy, string expectedConversion)
        {
            var sut = new GeneralTimeFormatter
            {
                NullFormat = nullFormat,
                Accuracy   = accuracy
            };

            var formattedTime = sut.Format(null);

            Assert.Equal(expectedConversion, formattedTime);
        }
Ejemplo n.º 6
0
        public void ConvertToExpectedValue_WhenAValidTimespanTextIsFormatted(string timespanText, DigitsFormat format, string expectedTime)
        {
            var sut = new GeneralTimeFormatter
            {
                DigitsFormat = format,
                Accuracy     = TimeAccuracy.Seconds
            };

            var time = TimeSpan.Parse(timespanText);

            var formattedTime = sut.Format(time);

            Assert.Equal(expectedTime, formattedTime);
        }
Ejemplo n.º 7
0
        public void FormatsTimCorrectly_WhenShowDaysIsTrue(string timespanText, DigitsFormat format, string expectedTime)
        {
            var sut = new GeneralTimeFormatter
            {
                DigitsFormat = format,
                ShowDays     = true,
                Accuracy     = TimeAccuracy.Seconds
            };

            var time          = TimeSpan.Parse(timespanText);
            var formattedTime = sut.Format(time);

            Assert.Equal(expectedTime, formattedTime);
        }
Ejemplo n.º 8
0
        public void TestTimeAccuracy(string timespanText, string expected, TimeAccuracy accuracy)
        {
            var formatter = new GeneralTimeFormatter();

            formatter.DigitsFormat = DigitsFormat.SingleDigitMinutes;
            formatter.Accuracy     = accuracy;

            TimeSpan?time = null;

            if (timespanText != null)
            {
                time = TimeSpan.Parse(timespanText);
            }

            string formatted = formatter.Format(time);

            Assert.AreEqual(expected, formatted);
        }
Ejemplo n.º 9
0
        public void TestDigitsFormat(string timespanText, string expected, DigitsFormat format)
        {
            var formatter = new GeneralTimeFormatter();

            formatter.DigitsFormat = format;
            formatter.Accuracy     = TimeAccuracy.Seconds;

            TimeSpan?time = null;

            if (timespanText != null)
            {
                time = TimeSpan.Parse(timespanText);
            }

            string formatted = formatter.Format(time);

            Assert.AreEqual(expected, formatted);
        }