ComparerTest.cs 849 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // ComparerTest
  2. using System;
  3. using System.Collections;
  4. using NUnit.Framework;
  5. namespace MonoTests.System.Collections {
  6. /// <summary>Comparer test suite.</summary>
  7. public class ComparerTest : TestCase {
  8. protected override void SetUp ()
  9. {
  10. }
  11. public void TestDefaultInstance ()
  12. {
  13. // Make sure the instance returned by Default
  14. // is really a Comparer.
  15. Assert((Comparer.Default as Comparer) != null);
  16. }
  17. public void TestCompare ()
  18. {
  19. Comparer c = Comparer.Default;
  20. bool thrown = false;
  21. try {
  22. c.Compare (new Object (), new Object ());
  23. } catch (ArgumentException) {
  24. thrown = true;
  25. }
  26. Assert("ArgumentException expected", thrown);
  27. Assert(c.Compare (1, 2) < 0);
  28. Assert(c.Compare (2, 2) == 0);
  29. Assert(c.Compare (3, 2) > 0);
  30. }
  31. }
  32. }