public async void TestInsertQueryParameters() { var personGuid = Guid.NewGuid(); var person = new Person() { Age = 50, DateOfBirth = DateTime.Now.AddYears(-50), Id = personGuid, Name = "neo", Salary = 5400.77, }; var context = new NeoContext(Driver); var parameters = new Dictionary <string, object>(); parameters.Add("p1", "neo"); parameters.Add("p2", personGuid); parameters.Add("p3", person.DateOfBirth); parameters.Add("p4", person.Salary); var resultExecuting = await context.Insert("CREATE (:Person { Name : $p1 , Id: $p2, DateOfBirth: $p3 , Salary: $p4 })", parameters); var resultPerson = await context.QueryDefault <Person>("MATCH (p:Person { Name: $p1 , Id: $p2 }) RETURN p", parameters); Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly); Assert.True(person.Id == resultPerson.Id); await context.ExecuteQuery("MATCH (p:Person) DETACH DELETE p"); }
public async void TestUpdateNode() { var personGuid = Guid.NewGuid(); var person = new Person() { Age = 50, DateOfBirth = DateTime.Now.AddYears(-50), Id = personGuid, Name = "neo", Salary = 5400.77, }; IDictionary <string, object> parameters = new Dictionary <string, object>() { { "Id", personGuid } }; var context = new NeoContext(Driver); IResultSummary resultExecuting = await context.InsertNode <Person>(person); person.Age = 55; await context.Update <Person>("MATCH (p:Person { Id : $Id} )", parameters, "p", person); var resultPerson = await context.QueryDefault <Person>("MATCH (p:Person { Id : $Id} ) return p", parameters); Assert.Equal <Person>(person, resultPerson); await context.ExecuteQuery("MATCH (p:Person) DETACH DELETE p"); }
public async void TestDefault() { var context = new NeoContext(Driver); var parameters = new Dictionary <string, object>(); parameters.Add("Country", "NotExist"); var result = await context.QueryDefault <Country>("MATCH(n:Country {countryName:$Country}) return n", parameters); Assert.Null(result); }
public async void TestCommitTransaction() { var expectedCountry = new Country() { CountryID = "555", CountryName = "NOM COUNTRY" }; var context = new NeoContext(Driver); await context.UseTransaction((transaction) => { transaction.Insert("CREATE (:Country { CountryID: '555' , countryName: 'NOM COUNTRY'})").GetAwaiter().GetResult(); var shouldBeNull = context.QueryDefault <Country>("MATCH (n:Country { CountryID: '555' }) RETURN n").GetAwaiter().GetResult(); Assert.Null(shouldBeNull); transaction.CommitTransaction().GetAwaiter().GetResult(); }); var resultCountry = await context.QueryDefault <Country>("MATCH (n:Country { CountryID: '555' }) RETURN n"); Assert.True(IsEqual(expectedCountry, resultCountry)); await context.ExecuteQuery("MATCH (n:Country { CountryID: '555' }) DETACH DELETE n"); }
public async void TestSingleQuery() { var expected = new Country() { CountryID = "186", CountryName = "Russia" }; INeoContext context = new NeoContext(Driver); Country result = await context.QueryDefault <Country>("MATCH(n:Country {countryName:'Russia'}) return n"); Assert.NotNull(result); Assert.True(IsEqual(result, expected)); }
public async void TestInsertQueryGeneric() { var expectedCountry = new Country() { CountryID = "555", CountryName = "NOM COUNTRY" }; var context = new NeoContext(Driver); var resultExecuting = await context.InsertNode <Country>(expectedCountry); var resultCountry = await context.QueryDefault <Country>("MATCH (n:Country { CountryID: '555' }) RETURN n"); Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly); Assert.True(IsEqual(expectedCountry, resultCountry)); await context.ExecuteQuery("MATCH (n:Country { CountryID: '555' }) DETACH DELETE n"); }
public async void TestSingleQueryParameter() { var expected = new Country() { CountryID = "186", CountryName = "Russia" }; var context = new NeoContext(Driver); var parameters = new Dictionary <string, object>(); parameters.Add("Country", "Russia"); var result = await context.QueryDefault <Country>("MATCH(n:Country {countryName:$Country}) return n", parameters); Assert.NotNull(result); Assert.True(IsEqual(result, expected)); }
public async void TestInsertQuery() { var person = new Person() { Age = 50, DateOfBirth = DateTime.Now.AddYears(-50), Id = Guid.NewGuid(), Name = "neo", Salary = 5400.77, }; var context = new NeoContext(Driver); IResultSummary resultExecuting = await context.InsertNode <Person>(person); var resultPerson = await context.QueryDefault <Person>("MATCH (p:Person) RETURN p"); Assert.True(resultExecuting.QueryType == Neo4j.Driver.QueryType.WriteOnly); Assert.Equal <Person>(person, resultPerson); await context.ExecuteQuery("MATCH (p:Person { Name : 'neo' }) DETACH DELETE p"); }