tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [12/50] [abbrv] tinkerpop git commit: Reorganize Gremlin-DotNet
Date Tue, 18 Jul 2017 13:08:49 GMT
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs
b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs
deleted file mode 100644
index d643440..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversalStrategy.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-#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 System.Threading.Tasks;
-using Gremlin.Net.Process.Traversal;
-
-namespace Gremlin.Net.Process.UnitTest.Traversal
-{
-    public class TestTraversalStrategy : ITraversalStrategy
-    {
-        private readonly IEnumerable<Traverser> _traversers;
-
-        public TestTraversalStrategy(IEnumerable<Traverser> traversersToAddOnApplication)
-        {
-            _traversers = traversersToAddOnApplication;
-        }
-
-        public void Apply(ITraversal traversal)
-        {
-            traversal.Traversers = _traversers;
-        }
-
-        public Task ApplyAsync(ITraversal traversal)
-        {
-            traversal.Traversers = _traversers;
-            return Task.CompletedTask;
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs
b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs
deleted file mode 100644
index a823a5d..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraversalTests.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-#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;
-using System.Collections.Generic;
-using System.Linq;
-using Gremlin.Net.Process.Traversal;
-using Moq;
-using Xunit;
-
-namespace Gremlin.Net.Process.UnitTest.Traversal
-{
-    public class TraversalTests
-    {
-        [Theory]
-        [InlineData(1)]
-        [InlineData("test")]
-        public void ShouldReturnAvailableTraverserObjWhenNextIsCalled(object traverserObj)
-        {
-            var traversal = new TestTraversal(new List<object> {traverserObj});
-
-            var actualObj = traversal.Next();
-
-            Assert.Equal(traverserObj, actualObj);
-        }
-
-        [Theory]
-        [InlineData(3)]
-        [InlineData(10)]
-        public void ShouldReturnCorrectNrOfResultObjsWhenNextIsCalledWithAmountArgument(int
nrOfResults)
-        {
-            var objs = new List<object>(20);
-            for (var i = 0; i < 20; i++)
-                objs.Add(i);
-            var traversal = new TestTraversal(objs);
-
-            var traversedObjs = traversal.Next(nrOfResults);
-
-            var traversedObjsList = traversedObjs.ToList();
-            Assert.Equal(nrOfResults, traversedObjsList.Count);
-            for (var i = 0; i < nrOfResults; i++)
-                Assert.Equal(objs[i], traversedObjsList[i]);
-        }
-
-        private List<object> UnfoldBulks(IReadOnlyList<object> objs, IReadOnlyList<long>
bulks)
-        {
-            var unfoldedObjs = new List<object>();
-            for (var traverserIdx = 0; traverserIdx < objs.Count; traverserIdx++)
-            for (var currentBulkObjIdx = 0; currentBulkObjIdx < bulks[traverserIdx]; currentBulkObjIdx++)
-                unfoldedObjs.Add(objs[traverserIdx]);
-            return unfoldedObjs;
-        }
-
-        [Fact]
-        public void ShouldDrainAllTraversersWhenIterateIsCalled()
-        {
-            var someObjs = new List<object> {1, 2, 3};
-            var traversal = new TestTraversal(someObjs);
-
-            var drainedTraversal = traversal.Iterate();
-
-            Assert.Null(drainedTraversal.Next());
-        }
-
-        [Fact]
-        public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable()
-        {
-            var expectedFirstObj = 1;
-            var traversal = new TestTraversal(new List<object> {expectedFirstObj});
-
-            var actualFirstObj = traversal.Next();
-            var actualSecondObj = traversal.Next();
-
-            Assert.Equal(expectedFirstObj, actualFirstObj);
-            Assert.Null(actualSecondObj);
-        }
-
-        [Fact]
-        public void ShouldReturnTraversalsTraverserWhenNextTraverserIsCalled()
-        {
-            var someObjs = new List<object> {1, 2, 3};
-            var traversal = new TestTraversal(someObjs);
-
-            var traverser = traversal.NextTraverser();
-
-            Assert.Equal(traversal.Traversers.First(), traverser);
-        }
-
-        [Fact]
-        public void ShouldThrowNotSupportedExceptionWhenResetIsCalled()
-        {
-            var someObjs = new List<object> {1, 2, 3};
-            var traversal = new TestTraversal(someObjs);
-
-            Assert.Throws<NotSupportedException>(() => traversal.Reset());
-        }
-
-        [Fact]
-        public void ShouldReturnAllTraverserObjsWhenToListIsCalled()
-        {
-            var expectedObjs = new List<object> {1, 2, 3};
-            var traversal = new TestTraversal(expectedObjs);
-
-            var traversedObjs = traversal.ToList();
-
-            Assert.Equal(expectedObjs, traversedObjs);
-        }
-
-        [Fact]
-        public void ShouldReturnAllTraverserObjWithoutDuplicatesWhenToSetIsCalled()
-        {
-            var traverserObjs = new List<object> {1, 1, 2, 3};
-            var traversal = new TestTraversal(traverserObjs);
-
-            var traversedObjSet = traversal.ToSet();
-
-            Assert.Equal(3, traversedObjSet.Count);
-            Assert.Equal(new HashSet<object>(traverserObjs), traversedObjSet);
-        }
-
-        [Fact]
-        public void ShouldApplyStrategiesWhenNextIsCalledAndNoTraversersPresent()
-        {
-            const int expectedObj = 531;
-            var testStrategy = new TestTraversalStrategy(new List<Traverser> {new Traverser(expectedObj)});
-            var testTraversal = new TestTraversal(new List<ITraversalStrategy> {testStrategy});
-
-            var actualObj = testTraversal.Next();
-
-            Assert.Equal(expectedObj, actualObj);
-        }
-
-        [Fact]
-        public void ShouldBeUnfoldTraverserBulksWhenToListIsCalled()
-        {
-            var objs = new List<object> {1, 2, 3};
-            var bulks = new List<long> {3, 2, 1};
-            var traversal = new TestTraversal(objs, bulks);
-
-            var traversedObjs = traversal.ToList();
-
-            var expectedObjs = UnfoldBulks(objs, bulks);
-            Assert.Equal(expectedObjs, traversedObjs);
-        }
-
-        [Fact]
-        public void ShouldDisposeSideEffectsWhenDisposeIsCalled()
-        {
-            var sideEffectsMock = new Mock<ITraversalSideEffects>();
-            var traversal = new TestTraversal(new List<object>()) {SideEffects = sideEffectsMock.Object};
-
-            traversal.Dispose();
-
-            sideEffectsMock.Verify(m => m.Dispose());
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs
b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs
deleted file mode 100644
index 4f6d2b5..0000000
--- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TraverserTests.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-#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 Gremlin.Net.Process.Traversal;
-using Xunit;
-
-namespace Gremlin.Net.Process.UnitTest.Traversal
-{
-    public class TraverserTests
-    {
-        [Fact]
-        public void ShouldReturnFalseForEqualsWhereOtherIsNull()
-        {
-            var traverser = new Traverser("anObject");
-
-            var areEqual = traverser.Equals(null);
-
-            Assert.False(areEqual);
-        }
-
-        [Fact]
-        public void ShouldReturnTrueForEqualsWithSameObjectAndDifferentBulk()
-        {
-            var firstTraverser = new Traverser("anObject", 1234);
-            var secondTraverser = new Traverser("anObject", 9876);
-
-            var areEqual = firstTraverser.Equals(secondTraverser);
-
-            Assert.True(areEqual);
-        }
-
-        [Fact]
-        public void ShouldReturnTrueForEqualsObjectWithSameObjectAndDifferentBulk()
-        {
-            var firstTraverser = new Traverser("anObject", 1234);
-            object secondTraverser = new Traverser("anObject", 9876);
-
-            var areEqual = firstTraverser.Equals(secondTraverser);
-
-            Assert.True(areEqual);
-        }
-
-        [Fact]
-        public void ShouldReturnEqualHashcodesForTraversersWithSameObjectAndDifferentBulk()
-        {
-            var firstTraverser = new Traverser("anObject", 1234);
-            var secondTraverser = new Traverser("anObject", 9876);
-
-            var firstHashCode = firstTraverser.GetHashCode();
-            var secondHashCode = secondTraverser.GetHashCode();
-
-            Assert.Equal(firstHashCode, secondHashCode);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
index 3d2da0d..6cf88ac 100644
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Gremlin.Net.UnitTest.csproj
@@ -13,7 +13,6 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <ProjectReference Include="..\..\src\Gremlin.Net.Process\Gremlin.Net.Process.csproj"
/>
     <ProjectReference Include="..\..\src\Gremlin.Net\Gremlin.Net.csproj" />
   </ItemGroup>
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs
new file mode 100644
index 0000000..da77223
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/BytecodeTests.cs
@@ -0,0 +1,44 @@
+#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 Gremlin.Net.Process.Traversal;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class BytecodeTests
+    {
+        [Fact]
+        public void ShouldUseBingings()
+        {
+            var bytecode = new Bytecode();
+            var bindings = new Bindings();
+
+            bytecode.AddStep("hasLabel", bindings.Of("label", "testLabel"));
+
+            var arg = bytecode.StepInstructions[0].Arguments[0];
+            var binding = arg as Binding;
+            Assert.Equal(new Binding("label", "testLabel"), binding);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
new file mode 100644
index 0000000..1ce1ec0
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/GraphTraversalSourceTests.cs
@@ -0,0 +1,68 @@
+#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 Gremlin.Net.Structure;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class GraphTraversalSourceTests
+    {
+        [Fact]
+        public void ShouldBeIndependentFromReturnedGraphTraversalModififyingBytecode()
+        {
+            var graph = new Graph();
+            var g = graph.Traversal();
+
+            g.V().Has("someKey", "someValue").Drop();
+
+            Assert.Equal(0, g.Bytecode.StepInstructions.Count);
+            Assert.Equal(0, g.Bytecode.SourceInstructions.Count);
+        }
+
+        [Fact]
+        public void ShouldBeIndependentFromReturnedGraphTraversalSourceModififyingBytecode()
+        {
+            var graph = new Graph();
+            var g1 = graph.Traversal();
+
+            var g2 = g1.WithSideEffect("someSideEffectKey", "someSideEffectValue");
+
+            Assert.Equal(0, g1.Bytecode.SourceInstructions.Count);
+            Assert.Equal(0, g1.Bytecode.StepInstructions.Count);
+            Assert.Equal(1, g2.Bytecode.SourceInstructions.Count);
+        }
+
+        [Fact]
+        public void ShouldBeIndependentFromReturnedGraphTraversalSourceModififyingTraversalStrategies()
+        {
+            var graph = new Graph();
+            var gLocal = graph.Traversal();
+
+            var gRemote = gLocal.WithRemote(null);
+
+            Assert.Equal(0, gLocal.TraversalStrategies.Count);
+            Assert.Equal(1, gRemote.TraversalStrategies.Count);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs
new file mode 100644
index 0000000..59af681
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/PredicateTests.cs
@@ -0,0 +1,50 @@
+#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 Gremlin.Net.Process.Traversal;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class PredicateTests
+    {
+        [Fact]
+        public void ShouldKeepOrderForNestedPredicate()
+        {
+            Assert.Equal("and(eq(a),lt(b))", P.Eq("a").And(P.Lt("b")).ToString());
+        }
+
+        [Fact]
+        public void ShouldKeepOrderForDoubleNestedPredicate()
+        {
+            Assert.Equal("and(or(lt(b),gt(c)),neq(d))", P.Lt("b").Or(P.Gt("c")).And(P.Neq("d")).ToString());
+        }
+
+        [Fact]
+        public void ShouldKeepOrderForTripleNestedPredicate()
+        {
+            Assert.Equal("and(or(lt(b),gt(c)),or(neq(d),gte(e)))",
+                P.Lt("b").Or(P.Gt("c")).And(P.Neq("d").Or(P.Gte("e"))).ToString());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs
new file mode 100644
index 0000000..47adb29
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/Strategy/StrategyTests.cs
@@ -0,0 +1,109 @@
+#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 Gremlin.Net.Process.Traversal.Strategy;
+using Gremlin.Net.Process.Traversal.Strategy.Optimization;
+using Gremlin.Net.Process.Traversal.Strategy.Verification;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal.Strategy
+{
+    public class StrategyTests
+    {
+        [Fact]
+        public void ShouldReturnFalseForEqualsOfStrategiesWithDifferentStrategyNames()
+        {
+            var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue");
+            var secondStrategy = new IncidentToAdjacentStrategy();
+
+            var areEqual = firstStrategy.Equals(secondStrategy);
+
+            Assert.False(areEqual);
+        }
+
+        [Fact]
+        public void ShouldReturnTrueForEqualsOfStrategiesWithEqualNamesButDifferentConfigurations()
+        {
+            var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue");
+            var secondStrategy = new TestStrategy("anotherKey", "anotherValue");
+
+            var areEqual = firstStrategy.Equals(secondStrategy);
+
+            Assert.True(areEqual);
+        }
+
+        [Fact]
+        public void ShouldReturnDifferentHashcodesForStrategiesWithDifferentNames()
+        {
+            var firstStrategy = new TestStrategy();
+            var secondStrategy = new ReadOnlyStrategy();
+
+            var firstHashCode = firstStrategy.GetHashCode();
+            var secondHashCode = secondStrategy.GetHashCode();
+
+            Assert.NotEqual(firstHashCode, secondHashCode);
+        }
+
+        [Fact]
+        public void ShouldReturnEqualHashcodesForStrategiesWithEqualNamesButDifferentConfigurations()
+        {
+            var firstStrategy = new TestStrategy("aConfigKey", "aConfigValue");
+            var secondStrategy = new TestStrategy("anotherKey", "anotherValue");
+
+            var firstHashCode = firstStrategy.GetHashCode();
+            var secondHashCode = secondStrategy.GetHashCode();
+
+            Assert.Equal(firstHashCode, secondHashCode);
+        }
+
+        [Fact]
+        public void ShouldReturnClassNameForStrategyNameProperty()
+        {
+            var testStrategy = new TestStrategy();
+
+            Assert.Equal("TestStrategy", testStrategy.StrategyName);
+        }
+
+        [Fact]
+        public void ShouldReturnStrategyNameWhenForToString()
+        {
+            var testStrategy = new TestStrategy();
+
+            var strategyStr = testStrategy.ToString();
+
+            Assert.Equal("TestStrategy", strategyStr);
+        }
+    }
+
+    internal class TestStrategy : AbstractTraversalStrategy
+    {
+        public TestStrategy()
+        {
+        }
+
+        public TestStrategy(string configKey, dynamic configValue)
+        {
+            Configuration[configKey] = configValue;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
new file mode 100644
index 0000000..4be6823
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversal.cs
@@ -0,0 +1,51 @@
+#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 System.Linq;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class TestTraversal : DefaultTraversal
+    {
+        public TestTraversal(List<object> traverserObjs)
+        {
+            var traversers = new List<Traverser>(traverserObjs.Count);
+            traverserObjs.ForEach(o => traversers.Add(new Traverser(o)));
+            Traversers = traversers;
+        }
+
+        public TestTraversal(IReadOnlyList<object> traverserObjs, IReadOnlyList<long>
traverserBulks)
+        {
+            var traversers = new List<Traverser>(traverserObjs.Count);
+            traversers.AddRange(traverserObjs.Select((t, i) => new Traverser(t, traverserBulks[i])));
+            Traversers = traversers;
+        }
+
+        public TestTraversal(IList<ITraversalStrategy> traversalStrategies)
+        {
+            TraversalStrategies = traversalStrategies;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs
new file mode 100644
index 0000000..111469c
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TestTraversalStrategy.cs
@@ -0,0 +1,50 @@
+#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 System.Threading.Tasks;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class TestTraversalStrategy : ITraversalStrategy
+    {
+        private readonly IEnumerable<Traverser> _traversers;
+
+        public TestTraversalStrategy(IEnumerable<Traverser> traversersToAddOnApplication)
+        {
+            _traversers = traversersToAddOnApplication;
+        }
+
+        public void Apply(ITraversal traversal)
+        {
+            traversal.Traversers = _traversers;
+        }
+
+        public Task ApplyAsync(ITraversal traversal)
+        {
+            traversal.Traversers = _traversers;
+            return Task.CompletedTask;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
new file mode 100644
index 0000000..f32b567
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraversalTests.cs
@@ -0,0 +1,177 @@
+#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;
+using System.Collections.Generic;
+using System.Linq;
+using Moq;
+using Xunit;
+using Gremlin.Net.Process.Traversal;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class TraversalTests
+    {
+        [Theory]
+        [InlineData(1)]
+        [InlineData("test")]
+        public void ShouldReturnAvailableTraverserObjWhenNextIsCalled(object traverserObj)
+        {
+            var traversal = new TestTraversal(new List<object> {traverserObj});
+
+            var actualObj = traversal.Next();
+
+            Assert.Equal(traverserObj, actualObj);
+        }
+
+        [Theory]
+        [InlineData(3)]
+        [InlineData(10)]
+        public void ShouldReturnCorrectNrOfResultObjsWhenNextIsCalledWithAmountArgument(int
nrOfResults)
+        {
+            var objs = new List<object>(20);
+            for (var i = 0; i < 20; i++)
+                objs.Add(i);
+            var traversal = new TestTraversal(objs);
+
+            var traversedObjs = traversal.Next(nrOfResults);
+
+            var traversedObjsList = traversedObjs.ToList();
+            Assert.Equal(nrOfResults, traversedObjsList.Count);
+            for (var i = 0; i < nrOfResults; i++)
+                Assert.Equal(objs[i], traversedObjsList[i]);
+        }
+
+        private List<object> UnfoldBulks(IReadOnlyList<object> objs, IReadOnlyList<long>
bulks)
+        {
+            var unfoldedObjs = new List<object>();
+            for (var traverserIdx = 0; traverserIdx < objs.Count; traverserIdx++)
+            for (var currentBulkObjIdx = 0; currentBulkObjIdx < bulks[traverserIdx]; currentBulkObjIdx++)
+                unfoldedObjs.Add(objs[traverserIdx]);
+            return unfoldedObjs;
+        }
+
+        [Fact]
+        public void ShouldDrainAllTraversersWhenIterateIsCalled()
+        {
+            var someObjs = new List<object> {1, 2, 3};
+            var traversal = new TestTraversal(someObjs);
+
+            var drainedTraversal = traversal.Iterate();
+
+            Assert.Null(drainedTraversal.Next());
+        }
+
+        [Fact]
+        public void ShouldReturnNullWhenNextIsCalledAndNoTraverserIsAvailable()
+        {
+            var expectedFirstObj = 1;
+            var traversal = new TestTraversal(new List<object> {expectedFirstObj});
+
+            var actualFirstObj = traversal.Next();
+            var actualSecondObj = traversal.Next();
+
+            Assert.Equal(expectedFirstObj, actualFirstObj);
+            Assert.Null(actualSecondObj);
+        }
+
+        [Fact]
+        public void ShouldReturnTraversalsTraverserWhenNextTraverserIsCalled()
+        {
+            var someObjs = new List<object> {1, 2, 3};
+            var traversal = new TestTraversal(someObjs);
+
+            var traverser = traversal.NextTraverser();
+
+            Assert.Equal(traversal.Traversers.First(), traverser);
+        }
+
+        [Fact]
+        public void ShouldThrowNotSupportedExceptionWhenResetIsCalled()
+        {
+            var someObjs = new List<object> {1, 2, 3};
+            var traversal = new TestTraversal(someObjs);
+
+            Assert.Throws<NotSupportedException>(() => traversal.Reset());
+        }
+
+        [Fact]
+        public void ShouldReturnAllTraverserObjsWhenToListIsCalled()
+        {
+            var expectedObjs = new List<object> {1, 2, 3};
+            var traversal = new TestTraversal(expectedObjs);
+
+            var traversedObjs = traversal.ToList();
+
+            Assert.Equal(expectedObjs, traversedObjs);
+        }
+
+        [Fact]
+        public void ShouldReturnAllTraverserObjWithoutDuplicatesWhenToSetIsCalled()
+        {
+            var traverserObjs = new List<object> {1, 1, 2, 3};
+            var traversal = new TestTraversal(traverserObjs);
+
+            var traversedObjSet = traversal.ToSet();
+
+            Assert.Equal(3, traversedObjSet.Count);
+            Assert.Equal(new HashSet<object>(traverserObjs), traversedObjSet);
+        }
+
+        [Fact]
+        public void ShouldApplyStrategiesWhenNextIsCalledAndNoTraversersPresent()
+        {
+            const int expectedObj = 531;
+            var testStrategy = new TestTraversalStrategy(new List<Traverser> {new Traverser(expectedObj)});
+            var testTraversal = new TestTraversal(new List<ITraversalStrategy> {testStrategy});
+
+            var actualObj = testTraversal.Next();
+
+            Assert.Equal(expectedObj, actualObj);
+        }
+
+        [Fact]
+        public void ShouldBeUnfoldTraverserBulksWhenToListIsCalled()
+        {
+            var objs = new List<object> {1, 2, 3};
+            var bulks = new List<long> {3, 2, 1};
+            var traversal = new TestTraversal(objs, bulks);
+
+            var traversedObjs = traversal.ToList();
+
+            var expectedObjs = UnfoldBulks(objs, bulks);
+            Assert.Equal(expectedObjs, traversedObjs);
+        }
+
+        [Fact]
+        public void ShouldDisposeSideEffectsWhenDisposeIsCalled()
+        {
+            var sideEffectsMock = new Mock<ITraversalSideEffects>();
+            var traversal = new TestTraversal(new List<object>()) {SideEffects = sideEffectsMock.Object};
+
+            traversal.Dispose();
+
+            sideEffectsMock.Verify(m => m.Dispose());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fec3ca5c/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs
b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs
new file mode 100644
index 0000000..f8963d3
--- /dev/null
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Process/Traversal/TraverserTests.cs
@@ -0,0 +1,75 @@
+#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 Gremlin.Net.Process.Traversal;
+using Xunit;
+
+namespace Gremlin.Net.UnitTest.Process.Traversal
+{
+    public class TraverserTests
+    {
+        [Fact]
+        public void ShouldReturnFalseForEqualsWhereOtherIsNull()
+        {
+            var traverser = new Traverser("anObject");
+
+            var areEqual = traverser.Equals(null);
+
+            Assert.False(areEqual);
+        }
+
+        [Fact]
+        public void ShouldReturnTrueForEqualsWithSameObjectAndDifferentBulk()
+        {
+            var firstTraverser = new Traverser("anObject", 1234);
+            var secondTraverser = new Traverser("anObject", 9876);
+
+            var areEqual = firstTraverser.Equals(secondTraverser);
+
+            Assert.True(areEqual);
+        }
+
+        [Fact]
+        public void ShouldReturnTrueForEqualsObjectWithSameObjectAndDifferentBulk()
+        {
+            var firstTraverser = new Traverser("anObject", 1234);
+            object secondTraverser = new Traverser("anObject", 9876);
+
+            var areEqual = firstTraverser.Equals(secondTraverser);
+
+            Assert.True(areEqual);
+        }
+
+        [Fact]
+        public void ShouldReturnEqualHashcodesForTraversersWithSameObjectAndDifferentBulk()
+        {
+            var firstTraverser = new Traverser("anObject", 1234);
+            var secondTraverser = new Traverser("anObject", 9876);
+
+            var firstHashCode = firstTraverser.GetHashCode();
+            var secondHashCode = secondTraverser.GetHashCode();
+
+            Assert.Equal(firstHashCode, secondHashCode);
+        }
+    }
+}
\ No newline at end of file


Mime
View raw message