public void Can_parse_hexadecimal_numbers() { var unparsedSlotNumber = "#8E"; var parsedSlotNumber = SlotNumber.Parse(unparsedSlotNumber); var expected = new SlotNumber(2, 3); Assert.AreEqual(expected, parsedSlotNumber); }
public void Can_parse_slot_slash_subslot_numbers() { var unparsedSlotNumber = "2-3"; var parsedSlotNumber = SlotNumber.Parse(unparsedSlotNumber); var expected = new SlotNumber(2, 3); Assert.AreEqual(expected, parsedSlotNumber); }
public void Can_parse_decimal_numbers() { var unparsedSlotNumber = (128 + 4 * 3 + 2).ToString(); var parsedSlotNumber = SlotNumber.Parse(unparsedSlotNumber); var expected = new SlotNumber(2, 3); Assert.AreEqual(expected, parsedSlotNumber); }
public void Can_deal_with_whitespace() { var strings = new[] { " 142 ", " #8E ", " 2-3 " }; var expected = new SlotNumber(2, 3); foreach (var s in strings) { Assert.AreEqual(expected, SlotNumber.Parse(s)); } }
public void Cannot_parse_invalid_strings() { Assert.Throws <ArgumentNullException>(() => SlotNumber.Parse(null)); var invalidStrings = new[] { "", "999", "abc", "#FFF", "#xx", "3-4", "-2", "1-", "a-b" }; foreach (var s in invalidStrings) { Assert.Throws <FormatException>(() => SlotNumber.Parse(s)); } }