Cole-Greer commented on code in PR #3315:
URL: https://github.com/apache/tinkerpop/pull/3315#discussion_r2962658011


##########
gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/Messages/RequestMessageTests.cs:
##########
@@ -0,0 +1,110 @@
+#region License
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Driver;
+using Gremlin.Net.Driver.Messages;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Driver.Messages
+{
+    public class RequestMessageTests
+    {
+        [Fact]
+        public void ShouldSetGremlinProperty()
+        {
+            var msg = RequestMessage.Build("g.V()").Create();
+
+            Assert.Equal("g.V()", msg.Gremlin);
+        }
+
+        [Fact]
+        public void ShouldSetDefaultLanguageField()
+        {
+            var msg = RequestMessage.Build("g.V()").Create();
+
+            Assert.Equal("gremlin-lang", msg.Fields[Tokens.ArgsLanguage]);
+        }
+
+        [Fact]
+        public void ShouldSetGField()
+        {
+            var msg = RequestMessage.Build("g.V()").AddG("g").Create();
+
+            Assert.Equal("g", msg.Fields[Tokens.ArgsG]);

Review Comment:
   Nit: It's better not to use the default value for this test
   ```suggestion
               var msg = RequestMessage.Build("g.V()").AddG("customG").Create();
   
               Assert.Equal("customG", msg.Fields[Tokens.ArgsG]);
   ```



##########
gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Util/RequestMessageProvider.cs:
##########
@@ -31,24 +29,17 @@ internal class RequestMessageProvider
     {
         public string GetSleepGremlinScript(int sleepTimeInMs)
         {
-            return $"Thread.sleep({sleepTimeInMs});";
+            return "g.inject(1)";
         }
 
         public RequestMessage GetSleepMessage(int sleepTimeInMs)
         {
-            var gremlinScript = $"Thread.sleep({nameof(sleepTimeInMs)});";
-            var bindings = new Dictionary<string, object> 
{{nameof(sleepTimeInMs), sleepTimeInMs}};
-            return
-                RequestMessage.Build(Tokens.OpsEval)
-                    .AddArgument(Tokens.ArgsGremlin, gremlinScript)
-                    .AddArgument(Tokens.ArgsBindings, bindings)
-                    .Create();
+            return RequestMessage.Build("g.inject(1)").Create();
         }

Review Comment:
   I don't think we should be modifying these methods to produce a dummy script 
instead of a proper sleep. They should either remain proper groovy sleeps (and 
force the tests to request `language: gremlin-groovy`), or be removed entirely.
   
   It appears they are currently unused so removal should be fine.



##########
gremlin-dotnet/test/Gremlin.Net.UnitTest/Driver/Messages/RequestMessageTests.cs:
##########
@@ -0,0 +1,110 @@
+#region License
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#endregion
+
+using System.Collections.Generic;
+using Gremlin.Net.Driver;
+using Gremlin.Net.Driver.Messages;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Driver.Messages
+{
+    public class RequestMessageTests
+    {
+        [Fact]
+        public void ShouldSetGremlinProperty()
+        {
+            var msg = RequestMessage.Build("g.V()").Create();
+
+            Assert.Equal("g.V()", msg.Gremlin);
+        }
+
+        [Fact]
+        public void ShouldSetDefaultLanguageField()
+        {
+            var msg = RequestMessage.Build("g.V()").Create();
+
+            Assert.Equal("gremlin-lang", msg.Fields[Tokens.ArgsLanguage]);
+        }
+
+        [Fact]
+        public void ShouldSetGField()
+        {
+            var msg = RequestMessage.Build("g.V()").AddG("g").Create();
+
+            Assert.Equal("g", msg.Fields[Tokens.ArgsG]);
+        }
+
+        [Fact]
+        public void ShouldSetBindings()
+        {
+            var msg = RequestMessage.Build("g.V(_0)")
+                .AddBinding("_0", 1)
+                .Create();
+
+            var bindings = (Dictionary<string, 
object>)msg.Fields[Tokens.ArgsBindings];
+            Assert.Equal(1, bindings["_0"]);
+        }
+
+        [Fact]
+        public void ShouldSetMultipleBindings()
+        {
+            var bindings = new Dictionary<string, object> { { "_0", 1 }, { 
"_1", "test" } };
+            var msg = RequestMessage.Build("g.V(_0).has(_1)")
+                .AddBindings(bindings)
+                .Create();
+
+            var resultBindings = (Dictionary<string, 
object>)msg.Fields[Tokens.ArgsBindings];
+            Assert.Equal(1, resultBindings["_0"]);
+            Assert.Equal("test", resultBindings["_1"]);
+        }
+
+        [Fact]
+        public void ShouldSetAdditionalField()
+        {
+            var msg = RequestMessage.Build("g.V()")
+                .AddField(Tokens.ArgsEvalTimeout, 5000L)
+                .Create();
+
+            Assert.Equal(5000L, msg.Fields[Tokens.ArgsEvalTimeout]);
+        }
+
+        [Fact]
+        public void ShouldReportHasField()
+        {
+            var builder = RequestMessage.Build("g.V()")
+                .AddField(Tokens.ArgsBulkResults, "true");
+
+            Assert.True(builder.HasField(Tokens.ArgsBulkResults));
+            Assert.False(builder.HasField("nonexistent"));
+        }
+
+        [Fact]
+        public void ShouldIncludeEmptyBindingsWhenNoneAdded()

Review Comment:
   Nit: I'm don't think it's necessary to attach empty bindings if none are 
provided, it's listed as an optional field in the HTTP API provider docs. It's 
probably fine to leave it in as well as the overhead should be negligible.



-- 
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