コード例 #1
0
        public async void TestGetRecordsWithParameters()
        {
            var expectedDic = new Dictionary <string, Country>()
            {
                { "186", new Country()
                  {
                      CountryID = "186", CountryName = "Russia"
                  } },
                { "216", new Country()
                  {
                      CountryID = "216", CountryName = "United States"
                  } }
            };
            var resultDic = new Dictionary <string, Country>();
            var context   = new NeoContext(Driver);
            var result    = await context.GetRecordsAsync("match(n:Country) WHERE n.countryID IN [$p1,$p2] return n", new Dictionary <string, object>()
            {
                { "p1", "186" },
                { "p2", "216" }
            });

            Assert.NotNull(result);
            foreach (var countryResult in result)
            {
                var nodeVal = countryResult.Values.First();
                var node    = nodeVal.Value as INode;
                var country = context.ConvertNodeToT <Country>(node);
                resultDic.Add(country.CountryID, country);
            }
            foreach (var country in expectedDic.Values)
            {
                Assert.True(IsEqual(country, resultDic[country.CountryID]));
            }
        }