public void SerializesGuidsProperlyWhenAutoGeneratingParams()
        {
            var mockSession = new Mock <ISession>();

            mockSession.Setup(s => s.Run("CALL dbms.components()")).Returns(new ServerInfo());

            var mockDriver = new Mock <IDriver>();

            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Uri).Returns(new Uri("bolt://localhost"));

            var bgc = new BoltGraphClient(mockDriver.Object);

            bgc.Connect();

            var cwg = new ClassWithGuid();

            bgc.Cypher.Create("(c)").Where((ClassWithGuid c) => c.Id == cwg.Id).ExecuteWithoutResults();

            var expectedParameters = new Dictionary <string, object> {
                { "p0", $"\"{cwg.Id}\"" }
            };

            mockSession.Verify(x => x.Run("CREATE (c)\r\nWHERE (c.Id = {p0})", It.Is <IDictionary <string, object> >(c => CompareDictionaries(c, expectedParameters))), Times.Once);
        }
        public void SerializesGuidsProperly()
        {
            var mockSession = new Mock <ISession>();

            mockSession.Setup(s => s.Run("CALL dbms.components()")).Returns(new ServerInfo());

            var mockDriver = new Mock <IDriver>();

            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Uri).Returns(new Uri("bolt://localhost"));

            var bgc = new BoltGraphClient(mockDriver.Object);

            bgc.Connect();

            var cwg = new ClassWithGuid();

            bgc.Cypher.Create("(c)").WithParam("testParam", cwg).ExecuteWithoutResults();

            var expectedParameters = new Dictionary <string, object>
            {
                { "testParam", new Dictionary <string, object> {
                      { "Id", cwg.Id.ToString() }
                  } }
            };

            mockSession.Verify(x => x.Run("CREATE (c)", It.Is <IDictionary <string, object> >(c => CompareDictionaries(c, expectedParameters))), Times.Once);
        }
Пример #3
0
        public void SerializesGuidsProperly()
        {
            var mockSession = new Mock <ISession>();

            mockSession.Setup(s => s.Run("CALL dbms.components()")).Returns(new ServerInfo());

            var mockDriver = new Mock <IDriver>();

            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>(), It.IsAny <IEnumerable <string> >())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Uri).Returns(new Uri("bolt://localhost"));

            var bgc = new BoltGraphClient(mockDriver.Object);

            bgc.Connect();

            var cwg = new ClassWithGuid();

            var cfq = bgc.Cypher.Create("(c)").WithParam("testParam", cwg);

            var expectedParameters = new Dictionary <string, object>
            {
                { "testParam", new Dictionary <string, object> {
                      { "Id", cwg.Id.ToString() }
                  } }
            };

            var query = cfq.Query;

            CompareDictionaries(query.ToNeo4jDriverParameters(bgc), expectedParameters).Should().BeTrue();
        }
Пример #4
0
        public void SerializesGuidsProperlyWhenAutoGeneratingParams()
        {
            var mockSession = new Mock <ISession>();

            mockSession.Setup(s => s.Run("CALL dbms.components()")).Returns(new ServerInfo());

            var mockDriver = new Mock <IDriver>();

            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Session(It.IsAny <AccessMode>(), It.IsAny <IEnumerable <string> >())).Returns(mockSession.Object);
            mockDriver.Setup(d => d.Uri).Returns(new Uri("bolt://localhost"));

            var bgc = new BoltGraphClient(mockDriver.Object);

            bgc.Connect();

            var cwg = new ClassWithGuid();

            var cfq = bgc.Cypher.Create("(c)").Where((ClassWithGuid c) => c.Id == cwg.Id);

            var expectedParameters = new Dictionary <string, object> {
                { "p0", $"{cwg.Id}" }
            };

            var query = cfq.Query;

            query.ToNeo4jDriverParameters(bgc).IsEqualTo(expectedParameters).Should().BeTrue();
        }
Пример #5
0
            public void SerializesGuidsCorrectly()
            {
                var cwg = new ClassWithGuid();

                var mockGc = new Mock<IRawGraphClient>();
                mockGc.Setup(x => x.JsonConverters).Returns(new List<JsonConverter>());

                var query = new CypherFluentQuery(mockGc.Object)
                    .Create("(t:Test {testParam})")
                    .WithParam("testParam", cwg);

                var parameters = query.Query.ToNeo4jDriverParameters(mockGc.Object);
                parameters.Should().NotBeNull();
                parameters.Count.Should().Be(1);
                var item = parameters.First();
                ((IDictionary<string, object>) item.Value)[nameof(ClassWithGuid.Id)].Should().BeOfType<string>();
                ((IDictionary<string, object>)item.Value)[nameof(ClassWithGuid.Id)].Should().Be(cwg.Id.ToString());
            }