Example #1
0
        public void DeltaComponentFormatterFormatsTimeAsDash_WhenTimeIsNullAndAccuracyIsInHundredths()
        {
            var sut = new DeltaComponentFormatter(TimeAccuracy.Hundredths, false);

            var formattedTime = sut.Format(null);

            Assert.Equal(TimeFormatConstants.DASH, formattedTime);
        }
Example #2
0
        public void DeltaComponentFormatterFormatsTimeCorrectly_WhenTimeIsValid(string timespanText, TimeAccuracy timeAccuracy, bool dropDecimals, string expectedDelta)
        {
            var sut  = new DeltaComponentFormatter(timeAccuracy, dropDecimals: dropDecimals);
            var time = TimeSpan.Parse(timespanText);

            var formattedTime = sut.Format(time);

            Assert.Equal(expectedDelta, formattedTime);
        }
Example #3
0
        public void TestDeltaComponentFormatter(string timespanText, TimeAccuracy timeAccuracy, bool dropDecimals, string expected)
        {
            var formatter = new DeltaComponentFormatter(timeAccuracy, dropDecimals: dropDecimals);

            TimeSpan?time = null;

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

            string formatted = formatter.Format(time);

            Assert.AreEqual(expected, formatted);
        }