コード例 #1
0
		public void GroupNameFromItem_Converter ()
		{
			// An invalid name means return null
			var ob = new Rectangle { Width = 100 };
			var converter = new ValueConverter {
				Converter = (value, targetType, parameter, culture) => {
					return Convert.ToInt32 (value) - 50;
				}
			};

			var p = new PropertyGroupDescription ("Width", converter);
			var result = p.GroupNameFromItem (ob, 0, null);
			Assert.IsInstanceOfType<int> (result, "#1");
			Assert.AreEqual (50, (int) result, "#2");
		}
コード例 #2
0
		public void GroupNameFromItem_Converter_CheckParameters()
		{
			// An invalid name means return null
			var ob = new Rectangle { Width = 100 };
			var converter = new ValueConverter {
				Converter = (value, targetType, parameter, culture) => {
					Assert.IsInstanceOfType<double> (value, "#1");
					Assert.AreEqual (100.0, (double) value, "#2");

					Assert.AreSame (typeof (object), targetType, "#3");

					Assert.IsInstanceOfType<int> (parameter, "#4");
					Assert.AreEqual (77, (int) parameter, "#5");

					Assert.IsNull (culture, "#6");
					return 50;
				}
			};

			var p = new PropertyGroupDescription ("Width", converter);
			p.GroupNameFromItem (ob, 77, null);
		}