Exemplo n.º 1
0
		public void CreateInstance_NullArguments ()
		{
			PaddingConverter c = new PaddingConverter ();
			try {
				c.CreateInstance (null, GetPropertiesTable (1, 1, 1, 1, 1));
				Assert.Fail ("#1");
			} catch (ArgumentNullException ex) { }
			try {
				c.CreateInstance (GetTypeDescriptorContext (Padding.Empty), null);
				Assert.Fail ("#2");
			} catch (ArgumentNullException ex) { }
		}
Exemplo n.º 2
0
		public void CreateInstance ()
		{
			PaddingConverter c = new PaddingConverter();
			Padding modified, expected;

			// Non-"All" Tests
			//
			ITypeDescriptorContext context = GetTypeDescriptorContext (new Padding (1, 2, 30, 40));

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (-1, 1, 2, 30, 40));
			expected = new Padding (1, 2, 30, 40);
			Assert.AreEqual (expected, modified, "NonAll_NoChange");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (-1, 111, 2, 30, 40));
			expected = new Padding (111, 2, 30, 40);
			Assert.AreEqual (expected, modified, "NonAll_ChangeLeft");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (-1, 1, 222, 30, 40));
			expected = new Padding (1, 222, 30, 40);
			Assert.AreEqual (expected, modified, "NonAll_ChangeTop");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (555, 1, 2, 30, 40));
			expected = new Padding (555);
			Assert.AreEqual (expected, modified, "NonAll_ChangeAll");

			// "All" tests
			//
			context = GetTypeDescriptorContext (new Padding (1));

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (1, 1, 1, 1, 1));
			expected = new Padding (1, 1, 1, 1);
			Assert.AreEqual (expected, modified, "All_NoChange");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (1, 111, 1, 1, 1));
			expected = new Padding (111, 1, 1, 1);
			Assert.AreEqual (expected, modified, "All_ChangeLeft");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (1, 1, 222, 1, 1));
			expected = new Padding (1, 222, 1, 1);
			Assert.AreEqual (expected, modified, "All_ChangeTop");

			modified = (Padding) c.CreateInstance (context, GetPropertiesTable (555, 1, 1, 1, 1));
			expected = new Padding (555);
			Assert.AreEqual (expected, modified, "All_ChangeAll");
		}