2
0

PrimitiveTesterTest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.ServiceModel;
  6. using MonoTests.Features;
  7. using MonoTests.Features.Contracts;
  8. using NUnit.Framework;
  9. using Proxy.MonoTests.Features.Client;
  10. namespace MonoTests.Features.Serialization
  11. {
  12. [TestFixture]
  13. public class PrimitiveTesterTest : TestFixtureBase<PrimitiveTesterContractClient, PrimitiveTester, MonoTests.Features.Contracts.IPrimitiveTesterContract>
  14. {
  15. [Test]
  16. public void TestDoNothing ()
  17. {
  18. Client.DoNothing ();
  19. }
  20. [Test]
  21. public void TestDouble () {
  22. Assert.IsTrue (Client.AddDouble (1, 1) == 2);
  23. }
  24. [Test]
  25. public void TestByte () {
  26. Assert.IsTrue (Client.AddByte (1, 1) == 2);
  27. }
  28. [Test]
  29. public void TestSByte () {
  30. Assert.IsTrue (Client.AddSByte (1, 1) == 2);
  31. }
  32. [Test]
  33. public void TestShort () {
  34. Assert.IsTrue (Client.AddShort (1, 1) == 2);
  35. }
  36. [Test]
  37. public void TestUShort () {
  38. Assert.IsTrue (Client.AddUShort (1, 1) == 2);
  39. }
  40. [Test]
  41. public void TestInt () {
  42. Assert.IsTrue (Client.AddInt (1, 1) == 2);
  43. }
  44. [Test]
  45. public void TestUInt () {
  46. Assert.IsTrue (Client.AddUInt (1, 1) == 2);
  47. }
  48. [Test]
  49. public void TestLong () {
  50. Assert.AreEqual (2, Client.AddLong (1, 1));
  51. }
  52. [Test]
  53. public void TestULong () {
  54. Assert.IsTrue (Client.AddULong (1, 1) == 2);
  55. }
  56. [Test]
  57. public void TestFloat () {
  58. Assert.IsTrue (Client.AddFloat (1, 1) == 2);
  59. }
  60. [Test]
  61. public void TestChar () {
  62. Assert.AreEqual (Client.AddChar ((char) 1, (char) 1), (char) 2);
  63. }
  64. [Test]
  65. public void TestByRef () {
  66. double d;
  67. double res = ClientProxy.AddByRef (out d, 1, 1);
  68. Assert.IsTrue(d == res);
  69. }
  70. [Test]
  71. [Category ("NotWorking")]
  72. public void TestNullableInt() {
  73. int? x1 = Client.NullableInt(3);
  74. Assert.AreEqual(x1,4,"TestNullableInt(3)==4");
  75. int? x2 = Client.NullableInt (null);
  76. Assert.IsNull (x2, "TestNullableInt(null)==null");
  77. }
  78. [Test]
  79. [Category ("NotWorking")]
  80. public void TestNullableFloat () {
  81. float? x1 = Client.NullableFloat ((float)1.5);
  82. Assert.AreEqual (x1, 2.5, "TestNullableFloat(1.5)==2.5");
  83. float? x2 = Client.NullableFloat (null);
  84. Assert.IsNull (x2, "TestNullableFloat(null)==null");
  85. }
  86. [Test]
  87. public void TestTimeSpan () {
  88. TimeSpan t1 = new TimeSpan (12345);
  89. TimeSpan t2 = new TimeSpan (12345);
  90. TimeSpan t3 = Client.AddTimeSpan (t1, t2);
  91. Assert.AreEqual (t3.Ticks, 24690);
  92. }
  93. [Test]
  94. public void TestByteArray () {
  95. byte [] b1 = new byte [] { 1, 2, 3, 4, 5 };
  96. byte [] b2 = new byte [] { 6, 7, 8, 9, 10 };
  97. byte [] sum = Client.AddByteArray (b1, b2);
  98. Assert.AreEqual (sum.Length, b1.Length, "Length of return array");
  99. Assert.AreEqual (sum [4], b1 [4] + b2 [4], "fourth element in return array");
  100. }
  101. }
  102. }