zcsizmadia commented on a change in pull request #1622:
URL: https://github.com/apache/avro/pull/1622#discussion_r835265125



##########
File path: lang/csharp/src/apache/test/Generic/GenericTests.cs
##########
@@ -17,28 +17,64 @@
  */
 using System;
 using System.IO;
-using System.Linq;
 using Avro.IO;
 using System.Collections.Generic;
+using System.Text;
 using Avro.Generic;
 using NUnit.Framework;
+using Decoder = Avro.IO.Decoder;
+using Encoder = Avro.IO.Encoder;
 
 namespace Avro.Test.Generic
 {
     class GenericTests
     {
-        private static void test<T>(string s, T value)
+        private static string intToUtf8(int value)
         {
-            Stream ms;
-            Schema ws;
-            serialize(s, value, out ms, out ws);
-            Schema rs = Schema.Parse(s);
-            T output = deserialize<T>(ms, ws, rs);
-            Assert.AreEqual(value, output);
+            var decimalLogicalType = new Avro.Util.Decimal();
+            var logicalSchema = (LogicalSchema)
+                Schema.Parse(@"{ ""type"": ""bytes"", ""logicalType"": 
""decimal"", ""precision"": 4 }");
+
+            byte[] byteArray = 
(byte[])decimalLogicalType.ConvertToBaseValue(new AvroDecimal(value), 
logicalSchema);

Review comment:
       I see your logic there. My intention was that if someone looks at the 
unit tests, it provides guidence about what to put phusically into the scheam 
as default value. Is there any higher level public function which can do what 
intToUtf8 does? I still feel uneasy about putting a very internal piece of code 
of the library into the unit test
   
   Btw I checked the code and the internal conversion code of the Decimal class 
can be modified, and the unit tests still pass. Which is not good and clearly a 
missing code coverage, but of course it is not in the scope of your PR.
   
   Most likely we need a  another PR to extend the code coverage of the Decimal 
object and cover the ConvertTo... public functions.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to