2
0

BindingMemberInfoTest.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2006 Novell, Inc.
  21. //
  22. // Authors:
  23. // Jackson Harper [email protected]
  24. using System;
  25. using System.Data;
  26. using System.Collections;
  27. using System.Windows.Forms;
  28. using NUnit.Framework;
  29. namespace MonoTests.System.Windows.Forms {
  30. [TestFixture]
  31. public class BindingMemberInfoTest {
  32. [Test]
  33. public void CtorNullTest ()
  34. {
  35. BindingMemberInfo bmi = new BindingMemberInfo (null);
  36. Assert.AreEqual (bmi.BindingMember, String.Empty, "CTORNULL1");
  37. Assert.AreEqual (bmi.BindingField, String.Empty, "CTORNULL2");
  38. Assert.AreEqual (bmi.BindingPath, String.Empty, "CTORNULL3");
  39. }
  40. [Test]
  41. public void CtorMemberOnly ()
  42. {
  43. BindingMemberInfo bmi = new BindingMemberInfo ("Member");
  44. Assert.AreEqual (bmi.BindingMember, "Member", "CTORMEMBER1");
  45. Assert.AreEqual (bmi.BindingField, "Member", "CTORMEMBER2");
  46. Assert.AreEqual (bmi.BindingPath, String.Empty, "CTORMEMBER3");
  47. }
  48. [Test]
  49. public void CtorMemberAndPathOnly ()
  50. {
  51. BindingMemberInfo bmi = new BindingMemberInfo ("Member.Path");
  52. Assert.AreEqual (bmi.BindingMember, "Member.Path", "CTMAF1");
  53. Assert.AreEqual (bmi.BindingPath, "Member", "CTMAF2");
  54. Assert.AreEqual (bmi.BindingField, "Path", "CTMAF3");
  55. }
  56. [Test]
  57. public void CtorAll ()
  58. {
  59. BindingMemberInfo bmi = new BindingMemberInfo ("Member.Path.Field");
  60. Assert.AreEqual (bmi.BindingMember, "Member.Path.Field", "CTALL1");
  61. Assert.AreEqual (bmi.BindingPath, "Member.Path", "CTALL2");
  62. Assert.AreEqual (bmi.BindingField, "Field", "CTALL3");
  63. }
  64. [Test]
  65. public void CtorEmpty ()
  66. {
  67. BindingMemberInfo bmi = new BindingMemberInfo ("...");
  68. Assert.AreEqual (bmi.BindingMember, "...", "CTEMPTY1");
  69. Assert.AreEqual (bmi.BindingPath, "..", "CTEMPTY2");
  70. Assert.AreEqual (bmi.BindingField, String.Empty, "CTEMPTY3");
  71. }
  72. [Test]
  73. public void CtorSpecialChars ()
  74. {
  75. BindingMemberInfo bmi = new BindingMemberInfo (",/';.[]-=!.$%&*~");
  76. Assert.AreEqual (bmi.BindingMember, ",/';.[]-=!.$%&*~", "CTORSPECIAL1");
  77. Assert.AreEqual (bmi.BindingPath, ",/';.[]-=!", "CTORSPECIAL2");
  78. Assert.AreEqual (bmi.BindingField, "$%&*~", "CTORSPECIAL3");
  79. }
  80. [Test]
  81. public void EqualsTest ()
  82. {
  83. BindingMemberInfo a = new BindingMemberInfo ("A.B.C");
  84. BindingMemberInfo b = new BindingMemberInfo ("A.B.C");
  85. Assert.AreEqual (a, b, "EQUALS1");
  86. b = new BindingMemberInfo ("A.B");
  87. Assert.IsFalse (a.Equals (b), "EQUALS2");
  88. }
  89. }
  90. }