public void TimeCueIndexerConverter_Converter_Convertion() { TimeCueIndexerConverter tcic = new TimeCueIndexerConverter(); TimeCueIndexer tci = tcic.ConvertFromString("05:43:67") as TimeCueIndexer; tci.Should().NotBeNull(); tci.Frames.Should().Be(67); tci.Minutes.Should().Be(5); tci.Seconds.Should().Be(43); TimeCueIndexer res = (TimeCueIndexer)tcic.ConvertFrom(new object()); res.Should().BeNull(); res = (TimeCueIndexer)tcic.ConvertFrom(null); res.TotalFrames.Should().Be(0); res = (TimeCueIndexer)tcic.ConvertFrom(string.Empty); res.TotalFrames.Should().Be(0); Action wt = () => res = (TimeCueIndexer)tcic.ConvertFrom("dddd"); wt.ShouldThrow<Exception>(); }
public void TimeCueIndexerConverter_Converter_Convertion_To_String() { TimeCueIndexerConverter tcic = new TimeCueIndexerConverter(); TimeCueIndexer tci = new TimeCueIndexer(1, 2, 3); string res = tcic.ConvertToString(tci); res.Should().Be("01:02:03"); TimeCueIndexer tci2 = new TimeCueIndexer(10, 20, 30); string res2 = tcic.ConvertToString(tci2); res2.Should().Be("10:20:30"); object Myres = tcic.ConvertTo(null, null, null, typeof(int)); Myres.Should().BeNull(); Myres = tcic.ConvertTo(null, null, null, typeof(string)); Myres.Should().Be(string.Empty); Action wt = () => tcic.ConvertTo(null, null, new object(), typeof(string)); wt.ShouldThrow<Exception>(); }
public void TimeCueIndexerConverter_Converter_Basic() { TimeCueIndexerConverter tcic = new TimeCueIndexerConverter(); tcic.CanConvertFrom(typeof(string)).Should().BeTrue(); tcic.CanConvertTo(typeof(string)).Should().BeTrue(); TypeDescriptor.GetConverter(typeof(TimeCueIndexer)).GetType().Should().Be(typeof(TimeCueIndexerConverter)); }
public void TimeCueIndexerConverter_Converter_TimeSpan() { TimeCueIndexerConverter tcic = new TimeCueIndexerConverter(); TimeCueIndexer tci = tcic.ConvertFromString("05:43:00") as TimeCueIndexer; tci.Should().NotBeNull(); TimeSpan ts = new TimeSpan(0, 5, 43); tci.ToTimeSpan().Should().Be(ts); }