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

            var formattedTime = sut.Format(null);

            Assert.Equal(TimeFormatConstants.DASH, formattedTime);
        }
示例#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);
        }
示例#3
0
 public DeltaComponent(LiveSplitState state)
 {
     Settings = new DeltaSettings()
     {
         CurrentState = state
     };
     Formatter                = new DeltaComponentFormatter(Settings.Accuracy, Settings.DropDecimals);
     InternalComponent        = new InfoTimeComponent(null, null, Formatter);
     state.ComparisonRenamed += state_ComparisonRenamed;
 }
示例#4
0
 public DeltaComponent(LiveSplitState state)
 {
     Settings = new DeltaSettings()
     {
         CurrentState = state
     };
     Formatter = new DeltaComponentFormatter(Settings.Accuracy, Settings.DropDecimals);
     InternalComponent = new InfoTimeComponent(null, null, Formatter);
     state.ComparisonRenamed += state_ComparisonRenamed;
 }
示例#5
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);
        }