public static string ISBNConvert10To13(this string isbn10, ISBNFormat format = ISBNFormat.None) { var isbn = isbn10.Replace(" ", "").Replace("-", ""); if (!Regex.IsMatch(isbn, @"^(\d{9}|\d{10}|\d{9}[Xx])$")) { throw new FormatException("ISBN 10 must be either 9 or 10 digits optinally with an x or X as the 10 character."); } var s = "978" + isbn[..9];
public void CreateValidISBNTest(string value) { ISBNFormat isbn = new ISBNFormat(value); Assert.AreEqual(value, isbn.Value); }