Example #1
0
        public void FromSelector_Uses_Class_Name_When_GremlinLabelAttribute_Is_Not_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Assert
            var result = client
                         .From <User>()
                         .BuildGremlinQuery();

            // Act
            Assert.AreEqual("g.V().has('label','User')", result);
        }
Example #2
0
        public void FromSelector_Uses_Given_Vertex_Label_When_GremlinLabelAttribute_Is_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Assert
            var result = client
                         .From <GremlinLabelTest>()
                         .BuildGremlinQuery();

            // Act
            Assert.AreEqual("g.V().has('label','gl')", result);
        }
        public void OutSelector_Traverses_With_Edge_Label_When_Label_Given()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .Out <Login>("unit test edge label")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','User').out('unit test edge label').has('label','Login')", result);
        }
Example #4
0
        public void Where_Uses_Given_Vertex_Label_When_GremlinPropertyAttribute_Is_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(u => u.StringProperty == "unit test value")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('sp', 'unit test value')", result);
        }
Example #5
0
        public void WhereIn_Uses_Quoted_Values_When_Property_Is_Integer()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .WhereIn(x => x.IntegerProperty, new object[] { 1, 2 })
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('sp',within(1, 2))", result);
        }
        public void ConnectedVertexSelector_Traverses_Using_Edge_Label()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .SelectOut <Login>("unit test edge label")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','User').out('unit test edge label').hasLabel('Login')", result);
        }
Example #7
0
        public void WhereIn_Uses_Class_Name_When_GremlinLabel_Not_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .WhereIn(x => x.FirstName, new[] { "a" })
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','User').has('FirstName',within('a'))", result);
        }
Example #8
0
        public void WhereIn_Uses_Quoted_Values_When_Property_Is_String()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .WhereIn(x => x.StringProperty, new[] { "a", "b" })
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('sp',within('a','b'))", result);
        }
Example #9
0
        public void Where_Does_Not_Quote_Value_When_Property_Is_Integer_And_Expression_Is_Negated_Equals_Method()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(a => !a.IntegerProperty.Equals(99))
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('ip', neq(99))", result);
        }
Example #10
0
        public void Where_Quotes_Value_When_Property_Is_String_And_Operator_Is_Inequality()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(a => a.StringProperty != "unit test value")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('sp', neq('unit test value'))", result);
        }
Example #11
0
        public void Where_Does_Not_Quote_Value_When_Property_Is_Integer_And_Operator_Is_Inequality()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(a => a.IntegerProperty != 99)
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('ip', neq(99))", result);
        }
Example #12
0
        public void Where_Quotes_Value_When_Property_Is_String_And_Expression_Is_Negated_Equals_Method()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(a => !a.StringProperty.Equals("unit test value"))
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('sp', neq('unit test value'))", result);
        }
Example #13
0
        public void Where_Does_Not_Quote_Value_When_Property_Is_Boolean_And_Operator_Is_Equality()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <GremlinPropertyTest>()
                         .Where(a => a.BooleanProperty)
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','GremlinPropertyTest').has('bp', true)", result);
        }
Example #14
0
        public void Where_Uses_Class_Name_When_GremlinPropertyAttribute_Is_Not_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .Where(u => u.FirstName == "unit test name")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual("g.V().has('label','User').has('FirstName', 'unit test name')", result);
        }
        public void DropCommand_Appends_Drop_To_Query()
        {
            // Arrange
            var client = new TestGraphClient();

            // Assert
            var result = client
                         .From <User>()
                         .Drop()
                         .BuildGremlinQuery();

            // Act
            Assert.AreEqual("g.V().has('label','User').drop()", result);
        }
Example #16
0
        public void As_Appends_Alias_To_Query()
        {
            // Arrange
            var client = new TestGraphClient();

            // Assert
            var result = client
                         .From <GremlinLabelTest>()
                         .As("unit test alias")
                         .BuildGremlinQuery();

            // Act
            Assert.AreEqual("g.V().has('label','gl').as('unit test alias')", result);
        }
Example #17
0
        public void As_Uses_GremlinLabel_When_Present()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .Out <Login>("unit test edge label")
                         .As <GremlinLabelTest>()
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual(
                "g.V().has('label','User').out('unit test edge label').has('label','Login').as('gl')",
                result);
        }
Example #18
0
        public void As_Adds_Alias_When_Alias_Inferred_By_Type()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .Out <Login>("unit test edge label")
                         .As <string>()
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual(
                "g.V().has('label','User').out('unit test edge label').has('label','Login').as('String')",
                result);
        }
        public void OutSelector_Adds_Alias_When_Alias_Given()
        {
            // Arrange
            var client = new TestGraphClient();

            // Act
            var result = client
                         .From <User>()
                         .Out <Login>("unit test edge label")
                         .As("unit test alias")
                         .BuildGremlinQuery();

            // Assert
            Assert.AreEqual(
                "g.V().has('label','User').out('unit test edge label').has('label','Login').as('unit test alias')",
                result);
        }