ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntikho...@apache.org
Subject [10/27] ignite git commit: IGNITE-2889 .NET: Added tests for IBinaryNameMapper. This closes #578.
Date Tue, 29 Mar 2016 08:04:39 GMT
IGNITE-2889 .NET: Added tests for IBinaryNameMapper. This closes #578.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/166bce84
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/166bce84
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/166bce84

Branch: refs/heads/ignite-2004
Commit: 166bce84516e6c1c10381eb6fa4fe356c9b83e1d
Parents: 090144c
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Fri Mar 25 09:26:30 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Mar 25 09:26:30 2016 +0300

----------------------------------------------------------------------
 .../Binary/BinaryBuilderSelfTest.cs             | 60 +++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/166bce84/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index e2f7d8a..1199790 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -17,6 +17,7 @@
 
 // ReSharper disable UnassignedField.Global
 // ReSharper disable CollectionNeverUpdated.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Global
 namespace Apache.Ignite.Core.Tests.Binary
 {
     using System;
@@ -83,9 +84,11 @@ namespace Apache.Ignite.Core.Tests.Binary
                         new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
                         new BinaryTypeConfiguration(typeof (DecimalHolder)),
                         new BinaryTypeConfiguration(TypeEmpty),
-                        new BinaryTypeConfiguration(typeof(TestEnumRegistered))
+                        new BinaryTypeConfiguration(typeof(TestEnumRegistered)),
+                        new BinaryTypeConfiguration(typeof(NameMapperTestType))
                     },
                     DefaultIdMapper = new IdMapper(),
+                    DefaultNameMapper = new NameMapper(),
                     CompactFooter = GetCompactFooter()
                 },
                 JvmClasspath = TestUtils.CreateTestClasspath(),
@@ -1382,6 +1385,22 @@ namespace Apache.Ignite.Core.Tests.Binary
         }
 
         /// <summary>
+        /// Tests type name mapper.
+        /// </summary>
+        [Test]
+        public void TestTypeName()
+        {
+            var bytes = _marsh.Marshal(new NameMapperTestType {NameMapperTestField = 17});
+
+            var bin = _marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+            var binType = bin.GetBinaryType();
+
+            Assert.AreEqual(BinaryUtils.GetStringHashCode(NameMapper.TestTypeName + "_"),
binType.TypeId);
+            Assert.AreEqual(17, bin.GetField<int>(NameMapper.TestFieldName));
+        }
+
+        /// <summary>
         /// Tests metadata methods.
         /// </summary>
         [Test]
@@ -1784,4 +1803,43 @@ namespace Apache.Ignite.Core.Tests.Binary
             return 0;
         }
     }
+
+    /// <summary>
+    /// Test name mapper.
+    /// </summary>
+    public class NameMapper : IBinaryNameMapper
+    {
+        /** */
+        public const string TestTypeName = "NameMapperTestType";
+
+        /** */
+        public const string TestFieldName = "NameMapperTestField";
+
+        /** <inheritdoc /> */
+        public string GetTypeName(string name)
+        {
+            if (name == TestTypeName)
+                return name + "_";
+
+            return name;
+        }
+
+        /** <inheritdoc /> */
+        public string GetFieldName(string name)
+        {
+            if (name == TestFieldName)
+                return name + "_";
+
+            return name;
+        }
+    }
+
+    /// <summary>
+    /// Name mapper test type.
+    /// </summary>
+    public class NameMapperTestType
+    {
+        /** */
+        public int NameMapperTestField { get; set; }
+    }
 }


Mime
View raw message