public void ConvertFrom() { var tsc = new TimeSpanConverter(); var timeSpan = tsc.ConvertFrom("1000"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.Parse("1000"), (TimeSpan) timeSpan); }
public void BaseConvertFrom() { var tsc = new TimeSpanConverter(); var timeSpan = tsc.ConvertFrom("00:00:10"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.FromSeconds(10), (TimeSpan) timeSpan); }
public void ConvertFromNullReference() { try { var tsc = new TimeSpanConverter(); tsc.ConvertFrom(null); } catch (NotSupportedException) { //.net throws NotSupportedException if (SystemUtils.MonoRuntime) { Assert.Fail("NotSupportedException not expected on mono"); } } catch (NullReferenceException) { //mono throws NullReferenceException if (!SystemUtils.MonoRuntime) { Assert.Fail("NRE not expected on .net"); } } }
public void ConvertFromStringMalformed() { var tsc = new TimeSpanConverter(); tsc.ConvertFrom("15a"); }
public void ConvertFromNonSupportedOptionBails() { var tsc = new TimeSpanConverter(); tsc.ConvertFrom(12); }
public void ConvertFromStringWithSecondSpecifier() { var tsc = new TimeSpanConverter(); var timeSpan = tsc.ConvertFrom("10s"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.FromSeconds(10), (TimeSpan) timeSpan); }
public void ConvertFromStringWithMinuteSpecifier() { var tsc = new TimeSpanConverter(); var timeSpan = tsc.ConvertFrom("2m"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.FromMinutes(2), (TimeSpan) timeSpan); }
public void ConvertFromStringWithHourSpecifier() { var tsc = new TimeSpanConverter(); var timeSpan = tsc.ConvertFrom("1H"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.FromHours(1), (TimeSpan) timeSpan); tsc.ConvertFrom("1h"); Assert.IsNotNull(timeSpan); Assert.IsTrue(timeSpan is TimeSpan); Assert.AreEqual(TimeSpan.FromHours(1), (TimeSpan) timeSpan); }