http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs deleted file mode 100644 index 8051167..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/SideEffectTests.cs +++ /dev/null @@ -1,221 +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 System.Threading.Tasks; -using Gremlin.CSharp.Structure; -using Xunit; - -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection -{ - public class SideEffectTests - { - private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); - - [Fact] - public void ShouldReturnCachedSideEffectWhenGetIsCalledAfterClose() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Aggregate("a").Iterate(); - - t.SideEffects.Get("a"); - t.SideEffects.Close(); - var results = t.SideEffects.Get("a"); - - Assert.NotNull(results); - } - - [Fact] - public void ShouldThrowWhenGetIsCalledAfterCloseAndNoSideEffectsAreCachec() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Aggregate("a").Iterate(); - - t.SideEffects.Close(); - Assert.Throws<InvalidOperationException>(() => t.SideEffects.Get("a")); - } - - [Fact] - public void ShouldThrowWhenGetIsCalledAfterDisposeAndNoSideEffectsAreCachec() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Aggregate("a").Iterate(); - - t.SideEffects.Dispose(); - Assert.Throws<InvalidOperationException>(() => t.SideEffects.Get("a")); - } - - [Fact] - public void ShouldReturnSideEffectValueWhenGetIsCalledForGroupCountTraversal() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); - t.SideEffects.Keys(); - - var m = t.SideEffects.Get("m") as Dictionary<string, dynamic>; - - Assert.Equal(2, m.Count); - Assert.Equal((long) 3, m["lop"]); - Assert.Equal((long) 1, m["ripple"]); - } - - [Fact] - public void ShouldReturnSideEffectValueWhenGetIsCalledOnATraversalWithSideEffect() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.WithSideEffect("a", new List<string> {"first", "second"}).V().Iterate(); - t.SideEffects.Keys(); - - var a = t.SideEffects.Get("a") as List<object>; - - Assert.Equal(2, a.Count); - Assert.Equal("first", a[0]); - Assert.Equal("second", a[1]); - } - - [Fact] - public void ShouldThrowWhenGetIsCalledWithAnUnknownKey() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Iterate(); - - Assert.Throws<KeyNotFoundException>(() => t.SideEffects.Get("m")); - } - - [Fact] - public void ShouldReturnBothSideEffectForTraversalWithTwoSideEffects_() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - - var t = g.V().Out("created").GroupCount("m").By("name").Values("name").Aggregate("n").Iterate(); - - var keys = t.SideEffects.Keys().ToList(); - Assert.Equal(2, keys.Count); - Assert.Contains("m", keys); - Assert.Contains("n", keys); - var n = (Dictionary<object, long>) t.SideEffects.Get("n"); - Assert.Equal(2, n.Count); - Assert.Equal(3, n["lop"]); - Assert.Equal(1, n["ripple"]); - } - - [Fact] - public void ShouldReturnAnEmptyCollectionWhenKeysIsCalledForTraversalWithoutSideEffect() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - - var t = g.V().Iterate(); - var keys = t.SideEffects.Keys(); - - Assert.Equal(0, keys.Count); - } - - [Fact] - public void ShouldReturnCachedKeysWhenForCloseAfterSomeGet() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Aggregate("a").Aggregate("b").Iterate(); - - t.SideEffects.Get("a"); - t.SideEffects.Close(); - var keys = t.SideEffects.Keys(); - - Assert.Equal(2, keys.Count); - Assert.Contains("a", keys); - Assert.Contains("b", keys); - } - - [Fact] - public void ShouldReturnSideEffectKeyWhenKeysIsCalledForNamedGroupCount() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); - - var keys = t.SideEffects.Keys(); - - var keysList = keys.ToList(); - Assert.Equal(1, keysList.Count); - Assert.Contains("m", keysList); - } - - [Fact] - public async Task ShouldReturnSideEffectsKeysWhenKeysIsCalledOnTraversalThatExecutedAsynchronously() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - - var t = await g.V().Aggregate("a").Promise(x => x); - var keys = t.SideEffects.Keys(); - - Assert.Equal(1, keys.Count); - Assert.Contains("a", keys); - } - - [Fact] - public async Task ShouldReturnSideEffectValueWhenGetIsCalledOnTraversalThatExecutedAsynchronously() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - - var t = await g.V().Aggregate("a").Promise(x => x); - var value = t.SideEffects.Get("a"); - - Assert.NotNull(value); - } - - [Fact] - public async Task ShouldNotThrowWhenCloseIsCalledOnTraversalThatExecutedAsynchronously() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection); - - var t = await g.V().Aggregate("a").Promise(x => x); - t.SideEffects.Close(); - } - } -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs deleted file mode 100644 index 59e2092..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/DriverRemoteConnection/StrategiesTests.cs +++ /dev/null @@ -1,193 +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.Threading.Tasks; -using Gremlin.CSharp.Process; -using Gremlin.CSharp.Structure; -using Gremlin.Net.Driver.Exceptions; -using Gremlin.Net.Process.Traversal.Strategy.Decoration; -using Gremlin.Net.Process.Traversal.Strategy.Verification; -using Xunit; - -namespace Gremlin.CSharp.IntegrationTest.DriverRemoteConnection -{ - public class StrategiesTests - { - private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); - - [Fact] - public void g_V_Count_Next_WithVertexLabelSubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); - - var count = g.V().Count().Next(); - - Assert.Equal((long) 4, count); - } - - [Fact] - public void g_E_Count_Next_WithVertexAndEdgeLabelSubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"), - edgeCriterion: __.HasLabel("created"))); - - var count = g.E().Count().Next(); - - Assert.Equal((long)0, count); - } - - [Fact] - public void g_V_Label_Dedup_Count_Next_WithVertexLabelSubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); - - var count = g.V().Label().Dedup().Count().Next(); - - Assert.Equal((long)1, count); - } - - [Fact] - public void g_V_Label_Dedup_Next_WWithVertexLabelSubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); - - var label = g.V().Label().Dedup().Next(); - - Assert.Equal("person", label); - } - - [Fact] - public void g_V_Count_Next_WithVertexHasPropertySubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); - - var count = g.V().Count().Next(); - - Assert.Equal((long)1, count); - } - - [Fact] - public void g_E_Count_Next_WithEdgeLimitSubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(edgeCriterion: __.Limit(0))); - - var count = g.E().Count().Next(); - - Assert.Equal((long)0, count); - } - - [Fact] - public void g_V_Label_Dedup_Next_WithVertexHasPropertySubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); - - var label = g.V().Label().Dedup().Next(); - - Assert.Equal("person", label); - } - - [Fact] - public void g_V_ValuesXnameX_Next_WithVertexHasPropertySubgraphStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = - graph.Traversal() - .WithRemote(connection) - .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); - - var name = g.V().Values("name").Next(); - - Assert.Equal("marko", name); - } - - [Fact] - public void g_V_Count_Next_WithComputer() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection).WithComputer(); - - var count = g.V().Count().Next(); - - Assert.Equal((long)6, count); - } - - [Fact] - public void g_E_Count_Next_WithComputer() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection).WithComputer(); - - var count = g.E().Count().Next(); - - Assert.Equal((long)6, count); - } - - [Fact] - public async Task ShouldThrowWhenModifyingTraversalSourceWithReadOnlyStrategy() - { - var graph = new Graph(); - var connection = _connectionFactory.CreateRemoteConnection(); - var g = graph.Traversal().WithRemote(connection).WithStrategies(new ReadOnlyStrategy()); - - await Assert.ThrowsAsync<ResponseException>(async () => await g.AddV("person").Promise(t => t.Next())); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.cs deleted file mode 100644 index 99a1b65..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/GraphSONWriterTests.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 Gremlin.CSharp.Process; -using Gremlin.Net.Structure.IO.GraphSON; -using Xunit; - -namespace Gremlin.CSharp.IntegrationTest -{ - public class GraphSONWriterTests - { - [Fact] - public void ShouldSerializeLongPredicateCorrectly() - { - var writer = CreateStandardGraphSONWriter(); - var predicate = P.Lt("b").Or(P.Gt("c")).And(P.Neq("d")); - - var graphSon = writer.WriteObject(predicate); - - const string expected = - "{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"and\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"or\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"lt\",\"value\":\"b\"}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"gt\",\"value\":\"c\"}}]}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"neq\",\"value\":\"d\"}}]}}"; - Assert.Equal(expected, graphSon); - } - - private GraphSONWriter CreateStandardGraphSONWriter() - { - return new GraphSONWriter(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj deleted file mode 100644 index 1e7a7d2..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Gremlin.CSharp.IntegrationTest.csproj +++ /dev/null @@ -1,38 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>netcoreapp1.0</TargetFramework> - <AssemblyName>Gremlin.CSharp.IntegrationTest</AssemblyName> - <PackageId>Gremlin.CSharp.IntegrationTest</PackageId> - <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> - <RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion> - <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> - <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> - <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> - </PropertyGroup> - - <ItemGroup> - <ProjectReference Include="..\..\src\Gremlin.CSharp\Gremlin.CSharp.csproj" /> - <ProjectReference Include="..\..\src\Gremlin.Net.Process\Gremlin.Net.Process.csproj" /> - <ProjectReference Include="..\..\src\Gremlin.Net\Gremlin.Net.csproj" /> - </ItemGroup> - - <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> - <PackageReference Include="xunit" Version="2.2.0" /> - <PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" /> - <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" /> - </ItemGroup> - - <ItemGroup> - <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> - </ItemGroup> - - <ItemGroup> - <None Update="appsettings.json"> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </None> - </ItemGroup> - -</Project> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs deleted file mode 100644 index 579426b..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +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.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Gremlin.CSharp.IntegrationTest")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("232f0f2b-178e-4214-99c7-cc4dc6710f44")] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json b/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json deleted file mode 100644 index 38007ec..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.IntegrationTest/appsettings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "TestServerIpAddress": "localhost", - "TestServerPort": 45950 -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs deleted file mode 100644 index bac2d55..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/GraphTraversalSourceTests.cs +++ /dev/null @@ -1,68 +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.CSharp.Structure; -using Xunit; - -namespace Gremlin.CSharp.UnitTest -{ - 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/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj deleted file mode 100644 index ea81928..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/Gremlin.CSharp.UnitTest.csproj +++ /dev/null @@ -1,21 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>netcoreapp1.1</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> - <PackageReference Include="xunit" Version="2.2.0" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\..\src\Gremlin.CSharp\Gremlin.CSharp.csproj" /> - </ItemGroup> - - <ItemGroup> - <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> - </ItemGroup> - -</Project> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.cs deleted file mode 100644 index c06fb68..0000000 --- a/gremlin-dotnet/test/Gremlin.CSharp.UnitTest/PredicateTests.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 Gremlin.CSharp.Process; -using Xunit; - -namespace Gremlin.CSharp.UnitTest -{ - 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/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj index f8407a9..c5f29da 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gremlin.Net.IntegrationTest.csproj @@ -19,7 +19,6 @@ </ItemGroup> <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/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs new file mode 100644 index 0000000..1afb7bb --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/BytecodeGenerationTests.cs @@ -0,0 +1,76 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration +{ + public class BytecodeGenerationTests + { + [Fact] + public void g_V_OutXcreatedX() + { + var g = new Graph().Traversal(); + + var bytecode = g.V().Out("created").Bytecode; + + Assert.Equal(0, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.StepInstructions.Count); + Assert.Equal("V", bytecode.StepInstructions[0].OperatorName); + Assert.Equal("out", bytecode.StepInstructions[1].OperatorName); + Assert.Equal("created", bytecode.StepInstructions[1].Arguments[0]); + Assert.Equal(1, bytecode.StepInstructions[1].Arguments.Length); + } + + [Fact] + public void g_WithSackX1X_E_GroupCount_ByXweightX() + { + var g = new Graph().Traversal(); + + var bytecode = g.WithSack(1).E().GroupCount().By("weight").Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal("withSack", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(3, bytecode.StepInstructions.Count); + Assert.Equal("E", bytecode.StepInstructions[0].OperatorName); + Assert.Equal("groupCount", bytecode.StepInstructions[1].OperatorName); + Assert.Equal("by", bytecode.StepInstructions[2].OperatorName); + Assert.Equal("weight", bytecode.StepInstructions[2].Arguments[0]); + Assert.Equal(0, bytecode.StepInstructions[0].Arguments.Length); + Assert.Equal(0, bytecode.StepInstructions[1].Arguments.Length); + Assert.Equal(1, bytecode.StepInstructions[2].Arguments.Length); + } + + [Fact] + public void AnonymousTraversal_Start_EmptyBytecode() + { + var bytecode = __.Start().Bytecode; + + Assert.Equal(0, bytecode.SourceInstructions.Count); + Assert.Equal(0, bytecode.StepInstructions.Count); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs new file mode 100644 index 0000000..418b0e2 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/BytecodeGeneration/StrategiesTests.cs @@ -0,0 +1,170 @@ +#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.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Process.Traversal.Strategy.Finalization; +using Gremlin.Net.Process.Traversal.Strategy.Optimization; +using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.BytecodeGeneration +{ + public class StrategiesTests + { + [Fact] + public void TraversalWithoutStrategies_AfterWithStrategiesWasCalled_WithStrategiesNotAffected() + { + var graph = new Graph(); + var g = graph.Traversal().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(2, bytecode.SourceInstructions.Count); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[1].OperatorName); + Assert.Equal(1, bytecode.SourceInstructions[1].Arguments.Length); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[1].Arguments[0]); + } + + [Fact] + public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithoutStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy(), new LazyBarrierStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new LazyBarrierStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + } + + [Fact] + public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithoutStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithoutStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withoutStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + } + + [Fact] + public void ShouldIncludeConfigurationInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new MatchAlgorithmStrategy("greedy")).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new MatchAlgorithmStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Contains("greedy", + ((MatchAlgorithmStrategy) bytecode.SourceInstructions[0].Arguments[0]).Configuration.Values); + } + + [Fact] + public void ShouldIncludeMultipleStrategiesInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + } + + [Fact] + public void ShouldIncludeOneStrategyInBytecodeWhenGivenToWithStrategies() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new ReadOnlyStrategy()).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal("ReadOnlyStrategy", bytecode.SourceInstructions[0].Arguments[0].ToString()); + Assert.Equal(new ReadOnlyStrategy().GetHashCode(), bytecode.SourceInstructions[0].Arguments[0].GetHashCode()); + Assert.Equal(0, g.TraversalStrategies.Count); + } + + [Fact] + public void TraversalWithStrategies_Strategies_ApplyToReusedGraphTraversalSource() + { + var graph = new Graph(); + var g = graph.Traversal().WithStrategies(new ReadOnlyStrategy(), new IncidentToAdjacentStrategy()); + + var bytecode = g.V().Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(2, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new ReadOnlyStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + Assert.Equal(new IncidentToAdjacentStrategy(), bytecode.SourceInstructions[0].Arguments[1]); + Assert.Equal(1, bytecode.StepInstructions.Count); + Assert.Equal("V", bytecode.StepInstructions[0].OperatorName); + } + + [Fact] + public void TraversalWithStrategies_StrategyWithTraversalInConfig_IncludeTraversalInInConfigInBytecode() + { + var graph = new Graph(); + var g = graph.Traversal(); + + var bytecode = g.WithStrategies(new SubgraphStrategy(__.Has("name", "marko"))).Bytecode; + + Assert.Equal(1, bytecode.SourceInstructions.Count); + Assert.Equal(1, bytecode.SourceInstructions[0].Arguments.Length); + Assert.Equal("withStrategies", bytecode.SourceInstructions[0].OperatorName); + Assert.Equal(new SubgraphStrategy(), bytecode.SourceInstructions[0].Arguments[0]); + SubgraphStrategy strategy = bytecode.SourceInstructions[0].Arguments[0]; + Assert.Equal(1, strategy.Configuration.Count); + Assert.Equal(typeof(GraphTraversal), strategy.Configuration["vertices"].GetType()); + GraphTraversal traversal = strategy.Configuration["vertices"]; + Assert.Equal("has", traversal.Bytecode.StepInstructions[0].OperatorName); + Assert.Equal(new List<string> {"name", "marko"}, traversal.Bytecode.StepInstructions[0].Arguments); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs new file mode 100644 index 0000000..6d0f529 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/EnumTests.cs @@ -0,0 +1,59 @@ +#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.Process.Traversal; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class EnumTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUseOrderDecrInByStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var orderedAges = g.V().Values("age").Order().By(Order.decr).ToList(); + + Assert.Equal(new List<object> {35, 32, 29, 27}, orderedAges); + } + + [Fact] + public void ShouldUseTLabelInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var personsCount = g.V().Has(T.label, "person").Count().Next(); + + Assert.Equal((long) 4, personsCount); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs new file mode 100644 index 0000000..0e56c2e --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalSourceTests.cs @@ -0,0 +1,55 @@ +#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.Process.Traversal; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class GraphTraversalSourceTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUseSideEffectSpecifiedInWithSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var results = g.WithSideEffect("a", new List<string> {"josh", "peter"}) + .V(1) + .Out("created") + .In("created") + .Values("name") + .Where(P.Within("a")) + .ToList(); + + Assert.Equal(2, results.Count); + Assert.Contains("josh", results); + Assert.Contains("peter", results); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs new file mode 100644 index 0000000..ba999f3 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/GraphTraversalTests.cs @@ -0,0 +1,169 @@ +#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 System.Threading.Tasks; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class GraphTraversalTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void g_V_Count() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Count().Next(); + + Assert.Equal((long) 6, count); + } + + [Fact] + public void g_VX1X_Next() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var vertex = (Vertex) g.V(1).Next(); + + Assert.Equal(new Vertex((long) 1), vertex); + Assert.Equal((long) 1, vertex.Id); + } + + [Fact] + public void g_VX1X_NextTraverser() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var traverser = g.V(1).NextTraverser(); + + Assert.Equal(new Traverser(new Vertex((long)1)), traverser); + } + + [Fact] + public void g_VX1X_ToList() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var list = g.V(1).ToList(); + + Assert.Equal(1, list.Count); + } + + [Fact] + public void g_V_RepeatXBothX_TimesX5X_NextX10X() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var result = g.V().Repeat(__.Both()).Times(5).Next(10); + + Assert.Equal(10, result.Count()); + } + + [Fact] + public void g_V_HasXname_markoX_ValueMap_Next() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var receivedValueMap = g.V().Has("name", "marko").ValueMap().Next(); + + var expectedValueMap = new Dictionary<string, dynamic> + { + {"age", new List<object> {29}}, + {"name", new List<object> {"marko"}} + }; + Assert.Equal(expectedValueMap, receivedValueMap); + } + + [Fact] + public void g_V_RepeatXOutX_TimesX2X_ValuesXNameX() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Repeat(__.Out()).Times(2).Values("name"); + var names = t.ToList(); + + Assert.Equal((long) 2, names.Count); + Assert.Contains("lop", names); + Assert.Contains("ripple", names); + } + + [Fact] + public void ShortestPathTest() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var shortestPath = + (Path) g.V(5).Repeat(__.Both().SimplePath()).Until(__.HasId(6)).Limit(1).Path().Next(); + + Assert.Equal((long) 4, shortestPath.Count); + Assert.Equal(new Vertex((long) 6), shortestPath[3]); + } + + [Fact] + public void ShouldUseBindingsInTraversal() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var b = new Bindings(); + var count = g.V().Has(b.Of("propertyKey", "name"), b.Of("propertyValue", "marko")).OutE().Count().Next(); + + Assert.Equal((long) 3, count); + } + + [Fact] + public async Task ShouldExecuteAsynchronouslyWhenPromiseIsCalled() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = await g.V().Count().Promise(t => t.Next()); + + Assert.Equal((long) 6, count); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs new file mode 100644 index 0000000..88587f6 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/PredicateTests.cs @@ -0,0 +1,58 @@ +#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 Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class PredicateTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldUsePredicatesCombinedWithPAndInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Has("age", P.Gt(30).And(P.Lt(35))).Count().Next(); + + Assert.Equal((long) 1, count); + } + + [Fact] + public void ShouldUsePWithinInHasStep() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var count = g.V().Has("name", P.Within("josh", "vadas")).Count().Next(); + + Assert.Equal((long) 2, count); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs new file mode 100644 index 0000000..ab67c26 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/RemoteConnectionFactory.cs @@ -0,0 +1,41 @@ +#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 Gremlin.Net.Driver; +using Gremlin.Net.Process.Remote; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + internal class RemoteConnectionFactory + { + private static readonly string TestHost = ConfigProvider.Configuration["TestServerIpAddress"]; + private static readonly int TestPort = Convert.ToInt32(ConfigProvider.Configuration["TestServerPort"]); + + public IRemoteConnection CreateRemoteConnection() + { + return new Net.Driver.Remote.DriverRemoteConnection( + new GremlinClient(new GremlinServer(TestHost, TestPort))); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs new file mode 100644 index 0000000..c3629bc --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/SideEffectTests.cs @@ -0,0 +1,221 @@ +#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 System.Threading.Tasks; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class SideEffectTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void ShouldReturnCachedSideEffectWhenGetIsCalledAfterClose() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Get("a"); + t.SideEffects.Close(); + var results = t.SideEffects.Get("a"); + + Assert.NotNull(results); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledAfterCloseAndNoSideEffectsAreCachec() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Close(); + Assert.Throws<InvalidOperationException>(() => t.SideEffects.Get("a")); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledAfterDisposeAndNoSideEffectsAreCachec() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Iterate(); + + t.SideEffects.Dispose(); + Assert.Throws<InvalidOperationException>(() => t.SideEffects.Get("a")); + } + + [Fact] + public void ShouldReturnSideEffectValueWhenGetIsCalledForGroupCountTraversal() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); + t.SideEffects.Keys(); + + var m = t.SideEffects.Get("m") as Dictionary<string, dynamic>; + + Assert.Equal(2, m.Count); + Assert.Equal((long) 3, m["lop"]); + Assert.Equal((long) 1, m["ripple"]); + } + + [Fact] + public void ShouldReturnSideEffectValueWhenGetIsCalledOnATraversalWithSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.WithSideEffect("a", new List<string> {"first", "second"}).V().Iterate(); + t.SideEffects.Keys(); + + var a = t.SideEffects.Get("a") as List<object>; + + Assert.Equal(2, a.Count); + Assert.Equal("first", a[0]); + Assert.Equal("second", a[1]); + } + + [Fact] + public void ShouldThrowWhenGetIsCalledWithAnUnknownKey() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Iterate(); + + Assert.Throws<KeyNotFoundException>(() => t.SideEffects.Get("m")); + } + + [Fact] + public void ShouldReturnBothSideEffectForTraversalWithTwoSideEffects_() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Out("created").GroupCount("m").By("name").Values("name").Aggregate("n").Iterate(); + + var keys = t.SideEffects.Keys().ToList(); + Assert.Equal(2, keys.Count); + Assert.Contains("m", keys); + Assert.Contains("n", keys); + var n = (Dictionary<object, long>) t.SideEffects.Get("n"); + Assert.Equal(2, n.Count); + Assert.Equal(3, n["lop"]); + Assert.Equal(1, n["ripple"]); + } + + [Fact] + public void ShouldReturnAnEmptyCollectionWhenKeysIsCalledForTraversalWithoutSideEffect() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = g.V().Iterate(); + var keys = t.SideEffects.Keys(); + + Assert.Equal(0, keys.Count); + } + + [Fact] + public void ShouldReturnCachedKeysWhenForCloseAfterSomeGet() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Aggregate("a").Aggregate("b").Iterate(); + + t.SideEffects.Get("a"); + t.SideEffects.Close(); + var keys = t.SideEffects.Keys(); + + Assert.Equal(2, keys.Count); + Assert.Contains("a", keys); + Assert.Contains("b", keys); + } + + [Fact] + public void ShouldReturnSideEffectKeyWhenKeysIsCalledForNamedGroupCount() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + var t = g.V().Out("created").GroupCount("m").By("name").Iterate(); + + var keys = t.SideEffects.Keys(); + + var keysList = keys.ToList(); + Assert.Equal(1, keysList.Count); + Assert.Contains("m", keysList); + } + + [Fact] + public async Task ShouldReturnSideEffectsKeysWhenKeysIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + var keys = t.SideEffects.Keys(); + + Assert.Equal(1, keys.Count); + Assert.Contains("a", keys); + } + + [Fact] + public async Task ShouldReturnSideEffectValueWhenGetIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + var value = t.SideEffects.Get("a"); + + Assert.NotNull(value); + } + + [Fact] + public async Task ShouldNotThrowWhenCloseIsCalledOnTraversalThatExecutedAsynchronously() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection); + + var t = await g.V().Aggregate("a").Promise(x => x); + t.SideEffects.Close(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs new file mode 100644 index 0000000..6c7d8b6 --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/DriverRemoteConnection/StrategiesTests.cs @@ -0,0 +1,193 @@ +#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.Threading.Tasks; +using Gremlin.Net.Driver.Exceptions; +using Gremlin.Net.Process.Traversal; +using Gremlin.Net.Process.Traversal.Strategy.Decoration; +using Gremlin.Net.Process.Traversal.Strategy.Verification; +using Gremlin.Net.Structure; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal.DriverRemoteConnection +{ + public class StrategiesTests + { + private readonly RemoteConnectionFactory _connectionFactory = new RemoteConnectionFactory(); + + [Fact] + public void g_V_Count_Next_WithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var count = g.V().Count().Next(); + + Assert.Equal((long) 4, count); + } + + [Fact] + public void g_E_Count_Next_WithVertexAndEdgeLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"), + edgeCriterion: __.HasLabel("created"))); + + var count = g.E().Count().Next(); + + Assert.Equal((long)0, count); + } + + [Fact] + public void g_V_Label_Dedup_Count_Next_WithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var count = g.V().Label().Dedup().Count().Next(); + + Assert.Equal((long)1, count); + } + + [Fact] + public void g_V_Label_Dedup_Next_WWithVertexLabelSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.HasLabel("person"))); + + var label = g.V().Label().Dedup().Next(); + + Assert.Equal("person", label); + } + + [Fact] + public void g_V_Count_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var count = g.V().Count().Next(); + + Assert.Equal((long)1, count); + } + + [Fact] + public void g_E_Count_Next_WithEdgeLimitSubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(edgeCriterion: __.Limit(0))); + + var count = g.E().Count().Next(); + + Assert.Equal((long)0, count); + } + + [Fact] + public void g_V_Label_Dedup_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var label = g.V().Label().Dedup().Next(); + + Assert.Equal("person", label); + } + + [Fact] + public void g_V_ValuesXnameX_Next_WithVertexHasPropertySubgraphStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = + graph.Traversal() + .WithRemote(connection) + .WithStrategies(new SubgraphStrategy(vertexCriterion: __.Has("name", "marko"))); + + var name = g.V().Values("name").Next(); + + Assert.Equal("marko", name); + } + + [Fact] + public void g_V_Count_Next_WithComputer() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithComputer(); + + var count = g.V().Count().Next(); + + Assert.Equal((long)6, count); + } + + [Fact] + public void g_E_Count_Next_WithComputer() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithComputer(); + + var count = g.E().Count().Next(); + + Assert.Equal((long)6, count); + } + + [Fact] + public async Task ShouldThrowWhenModifyingTraversalSourceWithReadOnlyStrategy() + { + var graph = new Graph(); + var connection = _connectionFactory.CreateRemoteConnection(); + var g = graph.Traversal().WithRemote(connection).WithStrategies(new ReadOnlyStrategy()); + + await Assert.ThrowsAsync<ResponseException>(async () => await g.AddV("person").Promise(t => t.Next())); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.cs new file mode 100644 index 0000000..d8ccabe --- /dev/null +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Process/Traversal/GraphSONWriterTests.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 Gremlin.Net.Structure.IO.GraphSON; +using Xunit; + +namespace Gremlin.Net.IntegrationTest.Process.Traversal +{ + public class GraphSONWriterTests + { + [Fact] + public void ShouldSerializeLongPredicateCorrectly() + { + var writer = CreateStandardGraphSONWriter(); + var predicate = P.Lt("b").Or(P.Gt("c")).And(P.Neq("d")); + + var graphSon = writer.WriteObject(predicate); + + const string expected = + "{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"and\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"or\",\"value\":[{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"lt\",\"value\":\"b\"}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"gt\",\"value\":\"c\"}}]}},{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"neq\",\"value\":\"d\"}}]}}"; + Assert.Equal(expected, graphSon); + } + + private GraphSONWriter CreateStandardGraphSONWriter() + { + return new GraphSONWriter(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj deleted file mode 100644 index 2345f31..0000000 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Gremlin.Net.Process.UnitTest.csproj +++ /dev/null @@ -1,22 +0,0 @@ -<Project Sdk="Microsoft.NET.Sdk"> - - <PropertyGroup> - <TargetFramework>netcoreapp1.1</TargetFramework> - </PropertyGroup> - - <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> - <PackageReference Include="Moq" Version="4.7.1" /> - <PackageReference Include="xunit" Version="2.2.0" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> - </ItemGroup> - - <ItemGroup> - <ProjectReference Include="..\..\src\Gremlin.Net.Process\Gremlin.Net.Process.csproj" /> - </ItemGroup> - - <ItemGroup> - <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> - </ItemGroup> - -</Project> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f61227bc/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs deleted file mode 100644 index de0a0b7..0000000 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/BytecodeTests.cs +++ /dev/null @@ -1,44 +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 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/f61227bc/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs deleted file mode 100644 index 2e7dc5e..0000000 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/Strategy/StrategyTests.cs +++ /dev/null @@ -1,109 +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.Strategy; -using Gremlin.Net.Process.Traversal.Strategy.Optimization; -using Gremlin.Net.Process.Traversal.Strategy.Verification; -using Xunit; - -namespace Gremlin.Net.Process.UnitTest.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/f61227bc/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs b/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs deleted file mode 100644 index 34f88df..0000000 --- a/gremlin-dotnet/test/Gremlin.Net.Process.UnitTest/Traversal/TestTraversal.cs +++ /dev/null @@ -1,51 +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.Linq; -using Gremlin.Net.Process.Traversal; - -namespace Gremlin.Net.Process.UnitTest.Traversal -{ - public class TestTraversal : Process.Traversal.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
