Beispiel #1
0
        public void BasicCompactTest()
        {
            var formatter = new TimeSpanFormatter(compact: true);

            Assert.Equal("1h, 0m, 0s", formatter.WriteToString(TimeSpan.FromHours(1)));
            Assert.Equal("1h, 5m, 1s", formatter.WriteToString(new TimeSpan(1, 5, 1)));
        }
Beispiel #2
0
        public void BasicTest()
        {
            ITextFormatter <TimeSpan> formatter = new TimeSpanFormatter();

            Assert.Equal("1 hour, 0 minutes, 0 seconds", formatter.WriteToString(TimeSpan.FromHours(1)));
            Assert.Equal("1 hour, 5 minutes, 1 second", formatter.WriteToString(new TimeSpan(1, 5, 1)));
            Assert.Equal("6 days, 1 hour, 5 minutes, 1 second", formatter.WriteToString(new TimeSpan(6, 1, 5, 1)));
            Assert.Equal("1 week, 1 day, 1 hour, 5 minutes, 1 second", formatter.WriteToString(new TimeSpan(8, 1, 5, 1)));
            Assert.Equal("2 weeks, 1 day, 1 hour, 5 minutes, 1 second", formatter.WriteToString(new TimeSpan(15, 1, 5, 1)));
        }
Beispiel #3
0
        public void BasicLocalizationTest()
        {
            var formatter = new TimeSpanFormatter(TimeLocalization.Create("de"));

            // ReSharper disable StringLiteralTypo
            Assert.Equal("1 Stunde, 0 Minuten, 0 Sekunden", formatter.WriteToString(TimeSpan.FromHours(1)));
            Assert.Equal("1 Stunde, 5 Minuten, 1 Sekunde", formatter.WriteToString(new TimeSpan(1, 5, 1)));
            Assert.Equal("6 Tage, 1 Stunde, 5 Minuten, 1 Sekunde", formatter.WriteToString(new TimeSpan(6, 1, 5, 1)));
            Assert.Equal("1 Woche, 1 Tag, 1 Stunde, 5 Minuten, 1 Sekunde", formatter.WriteToString(new TimeSpan(8, 1, 5, 1)));
            Assert.Equal("2 Wochen, 1 Tag, 1 Stunde, 5 Minuten, 1 Sekunde", formatter.WriteToString(new TimeSpan(15, 1, 5, 1)));
            // ReSharper restore StringLiteralTypo
        }
Beispiel #4
0
        public void BasicSeparatorTest()
        {
            var formatter = new TimeSpanFormatter(separator: " - ");
            var std       = formatter.WriteToString(TimeSpan.FromDays(1.234));

            Assert.Equal("1 day - 5 hours - 36 minutes - 57 seconds", std);
        }
Beispiel #5
0
        public void BasicPrecisionTest()
        {
            var formatter = new TimeSpanFormatter(precision: TimePart.Minute);
            var std       = formatter.WriteToString(TimeSpan.FromDays(1.234));

            Assert.Equal("1 day, 5 hours, 36 minutes", std);
        }