Ejemplo n.º 1
0
        public void DefaultImplementation()
        {
            var v = new MyValueSerializer();

            foreach (var val in test_values)
            {
                Assert.IsFalse(v.CanConvertToString(val, null), "CanConvertTo." + val);
                try {
                    v.ConvertToString(val, null);
                    Assert.Fail("ConvertTo." + val);
                } catch (NotSupportedException) {
                }
            }

            // The funny thing also applies to CanConvertToString() and ConvertToString().

            foreach (var str in test_strings)
            {
                Assert.IsFalse(v.CanConvertFromString(str, null), "CanConvertFrom." + str);
                try {
                    v.ConvertFromString(str, null);
                    Assert.Fail("ConvertFrom." + str);
                } catch (NotSupportedException) {
                }
            }

            Assert.AreEqual(typeof(NotSupportedException), v.CallGetConvertFromException(null).GetType(), "#1");
            Assert.AreEqual(typeof(NotSupportedException), v.CallGetConvertToException(null, typeof(int)).GetType(), "#2");
            Assert.IsFalse(v.TypeReferences(null, null).GetEnumerator().MoveNext(), "#3");
        }
Ejemplo n.º 2
0
		public void DefaultImplementation ()
		{
			var v = new MyValueSerializer ();

			foreach (var val in test_values) {
				Assert.IsFalse (v.CanConvertToString (val, null), "CanConvertTo." + val);
				try {
					v.ConvertToString (val, null);
					Assert.Fail ("ConvertTo." + val);
				} catch (NotSupportedException) {
				}
			}

			// The funny thing also applies to CanConvertToString() and ConvertToString().

			foreach (var str in test_strings) {
				Assert.IsFalse (v.CanConvertFromString (str, null), "CanConvertFrom." + str);
				try {
					v.ConvertFromString (str, null);
					Assert.Fail ("ConvertFrom." + str);
				} catch (NotSupportedException) {
				}
			}
			
			Assert.AreEqual (typeof (NotSupportedException), v.CallGetConvertFromException (null).GetType (), "#1");
			Assert.AreEqual (typeof (NotSupportedException), v.CallGetConvertToException (null, typeof (int)).GetType (), "#2");
			Assert.IsFalse (v.TypeReferences (null, null).GetEnumerator ().MoveNext (), "#3");
		}
Ejemplo n.º 3
0
		public void DefaultImplementation ()
		{
			var v = new MyValueSerializer ();

			int i = 0;
			foreach (var val in test_values) {
				Assert.IsFalse (v.CanConvertToString (val, null), "CanConvertTo." + val);
				try {
					v.ConvertToString (val, null);
					Assert.Fail ("ConvertTo." + val);
				} catch (NotSupportedException) {
				}
			}

			// The funny thing also applies to CanConvertToString() and ConvertToString().

			i = 0;
			foreach (var str in test_strings) {
				Assert.IsFalse (v.CanConvertFromString (str, null), "CanConvertFrom." + str);
				try {
					v.ConvertFromString (str, null);
					Assert.Fail ("ConvertFrom." + str);
				} catch (NotSupportedException) {
				}
			}
		}