Inheritance: ConfigurationConverterBase
コード例 #1
0
		public void ConvertFrom_FormatError ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();
			object o;

			o = cv.ConvertFrom (null, null, "100.5");
			Assert.IsNull (o, "A1");
		}
コード例 #2
0
		public void CanConvertTo ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();

			Assert.IsTrue (cv.CanConvertTo (null, typeof (string)), "A1");
			Assert.IsFalse (cv.CanConvertTo (null, typeof (TimeSpan)), "A2");
			Assert.IsFalse (cv.CanConvertTo (null, typeof (int)), "A3");
			Assert.IsFalse (cv.CanConvertTo (null, typeof (object)), "A4");
		}
コード例 #3
0
		public void ConvertFrom ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();
			object o;

			o = cv.ConvertFrom (null, null, "59");
			Assert.AreEqual (typeof (TimeSpan), o.GetType(), "A1");
			Assert.AreEqual ("00:00:59", o.ToString(), "A2");
			o = cv.ConvertFrom (null, null, "104");
			Assert.AreEqual ("00:01:44", o.ToString(), "A3");
		}
コード例 #4
0
		public void ConvertTo ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();
			TimeSpan ts;

			ts = TimeSpan.FromSeconds (59);
			Assert.AreEqual ("59", cv.ConvertTo (null, null, ts, typeof (string)), "A1");

			ts = TimeSpan.FromSeconds (144);
			Assert.AreEqual ("144", cv.ConvertTo (null, null, ts, typeof (string)), "A2");

			ts = TimeSpan.FromMilliseconds (3900);
			Assert.AreEqual ("3", cv.ConvertTo (null, null, ts, typeof (string)), "A2");
		}
コード例 #5
0
		public void ConvertFrom_TypeError ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();
			object o;

			o = cv.ConvertFrom (null, null, 59);
			Assert.IsNull (o, "A1");
		}
コード例 #6
0
		public void ConvertTo_TypeError2 ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();
			TimeSpan ts;

			ts = TimeSpan.FromSeconds (59);

			Assert.AreEqual ("59", cv.ConvertTo (null, null, ts, typeof (int)), "A1");
			Assert.AreEqual ("59", cv.ConvertTo (null, null, ts, null), "A2");
		}
コード例 #7
0
		public void ConvertTo_TypeError1 ()
		{
			TimeSpanSecondsConverter cv = new TimeSpanSecondsConverter ();

			Assert.AreEqual ("59", cv.ConvertTo (null, null, 59, typeof (string)), "A1");
		}