static void Main(string[] args) { string isbn = String.Empty; while (true) { Console.Write("Enter an ISBN number (including dashes): "); isbn = Console.ReadLine(); if (isbn == "") { break; } Console.WriteLine("That ISBN number is " + (ISBN.IsValid(isbn.Trim()) ? "VALID" : "INVALID")); } while (true) { Console.Write("Press any key to generate valid ISBNs: "); Console.ReadLine(); int maxLoops = 0; for (int i = 0; i < 10000; i++) { int loops = 0; isbn = ISBN.New(out loops); if (loops > maxLoops) { maxLoops = loops; } } Console.WriteLine("Max loops was: " + maxLoops.ToString()); } }
public void GeneratedISBNIsValid() { int loops = 0; string isbn = ISBN.New(out loops); Assert.That(ISBN.IsValid(isbn)); }
public void FiveHundredGeneratedISBNsAreValid() { int loops = 0; for (int i = 0; i < 500; i++) { string isbn = ISBN.New(out loops); Assert.That(ISBN.IsValid(isbn)); } }
public void InvalidISBNIsInvalid() { Assert.That(!ISBN.IsValid("0-7405-3269-9")); }
public void ValidISBNIsValid() { Assert.That(ISBN.IsValid("0-7475-3269-9")); }