public void TestInvalidElementStringParse() { try { // on the other hand, invalid combo strings should throw exceptions during conversion XMouseButtonCombo.Parse("NonExistentCombo"); Assert.Fail("Expected an exception because the parsed string has an invalid element name"); } catch (FormatException) {} }
public void TestInvalidModifiersOnlyStringParse() { try { // on the other hand, invalid combo strings should throw exceptions during conversion XMouseButtonCombo.Parse("Ctrl+Shift"); Assert.Fail("Expected an exception because the parsed string has no mouse button, only modifiers"); } catch (FormatException) {} }
public void TestInvalidStringParse() { try { // on the other hand, invalid combo strings should throw exceptions during conversion XMouseButtonCombo.Parse("\n"); Assert.Fail("Expected an exception because the parsed string has an invalid character"); } catch (FormatException) {} }
public void TestInvalidElementLeadingSeparatorStringParse() { try { // on the other hand, invalid combo strings should throw exceptions during conversion XMouseButtonCombo.Parse("+Right Mouse Button"); Assert.Fail("Expected an exception because of a leading separator in the parse string"); } catch (FormatException) {} }
public void TestEmptyStringParse() { // empty strings should parse to XMouseButtonCombo.None XMouseButtonCombo mouseButtonCombo = XMouseButtonCombo.Parse(string.Empty); Assert.AreEqual(XMouseButtonCombo.None, mouseButtonCombo, "empty strings should parse to XMouseButtonCombo.None"); }
private static void AssertStringParse(string sMouseButtonCombo, XMouseButtonCombo vMouseButtonCombo, CultureInfo culture, string message) { XMouseButtonCombo actualValue = XMouseButtonCombo.Parse(sMouseButtonCombo, culture); //System.Diagnostics.Trace.WriteLine(actualValue); Assert.AreEqual(vMouseButtonCombo, actualValue, "{0}: converting {1} which is {2}", message, sMouseButtonCombo, actualValue); }