CaseInsensitiveHashCodeProviderTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // CaseInsensitiveHashCodeProviderTest
  2. using System;
  3. using System.Collections;
  4. using NUnit.Framework;
  5. namespace MonoTests.System.Collections {
  6. /// <summary>CaseInsensitiveHashCodeProvider test suite.</summary>
  7. public class CaseInsensitiveHashCodeProviderTest : 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 CaseInsensitiveHashCodeProvider.
  15. Assert((CaseInsensitiveHashCodeProvider.Default
  16. as CaseInsensitiveHashCodeProvider) != null);
  17. }
  18. public void TestHashCode () {
  19. CaseInsensitiveHashCodeProvider cih = new CaseInsensitiveHashCodeProvider ();
  20. int h1 = cih.GetHashCode ("Test String");
  21. int h2 = cih.GetHashCode ("test string");
  22. int h3 = cih.GetHashCode ("TEST STRING");
  23. Assert("Mixed Case != lower case", h1 == h2);
  24. Assert("Mixed Case != UPPER CASE", h1 == h3);
  25. h1 = cih.GetHashCode ("one");
  26. h2 = cih.GetHashCode ("another");
  27. // Actually this is quite possible.
  28. Assert(h1 != h2);
  29. }
  30. }
  31. }