public void TestPenColourComboBox() { var penBox = new ComboBox(); penBox.Items.Insert(0, "Blue"); penBox.Items.Insert(1, "Red"); penBox.Items.Insert(2, "Green"); penBox.Items.Insert(3, "Orange"); penBox.Items.Insert(4, "Yellow"); PenColourClass.PenColourSet("blue"); penBox.SelectedIndex = penBox.FindStringExact("Blue"); if (penBox.SelectedIndex == 0) { try { Assert.IsTrue((string)penBox.SelectedItem == "Red"); } catch (Exception) { Console.WriteLine(@"This should throw as the index is set to 0 so 'blue'"); } } else if (penBox.SelectedIndex == 0) { Assert.IsTrue((string)penBox.SelectedItem == "Blue"); } }
public void TestPenColourChange() { String a = "blue"; PenColourClass.PenColourSet(a); Assert.IsTrue(PenColourClass.MyPen.Color.Equals(Color.Blue)); try { String b = "red"; PenColourClass.PenColourSet(b); Assert.IsTrue(PenColourClass.MyPen.Color.Equals(Color.Yellow)); } catch { Console.WriteLine(@"This should throw as index is not set to yellow."); } }