public void ConvertToExcelTest() { var converter = new TimeSpanConverter(); var typeConverterOptions = new TypeConverterOptions { CultureInfo = CultureInfo.CurrentCulture }; var dateTime = DateTime.Now; var timeSpan = new TimeSpan(dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond); // Valid conversions. Assert.AreEqual(timeSpan.ToString(), converter.ConvertToExcel(typeConverterOptions, timeSpan)); // Invalid conversions. Assert.AreEqual("1", converter.ConvertToExcel(typeConverterOptions, 1)); Assert.AreEqual(null, converter.ConvertToExcel(typeConverterOptions, null)); }