public void SerializesDateTimeOffsetsProperly()
        {
            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 cwd = new ClassWithDateTimeOffset {
                Dt = new DateTimeOffset(new DateTime(2000, 1, 1), TimeSpan.FromHours(1))
            };;

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

            var expectedParameters = new Dictionary <string, object>
            {
                {
                    "testParam", new Dictionary <string, object> {
                        { "Dt", JsonConvert.SerializeObject(cwd.Dt).Trim('\"') }
                    }
                }
            };

            mockSession.Verify(x => x.Run("CREATE (c)", It.Is <IDictionary <string, object> >(c => CompareDictionaries(c, expectedParameters))), Times.Once);
        }
Exemple #2
0
        public void SerializesDateTimeOffsetsProperly()
        {
            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 cwd = new ClassWithDateTimeOffset {
                Dt = new DateTimeOffset(new DateTime(2000, 1, 1), TimeSpan.FromHours(1))
            };;

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

            var expectedParameters = new Dictionary <string, object>
            {
                {
                    "testParam", new Dictionary <string, object> {
                        { "Dt", JsonConvert.SerializeObject(cwd.Dt).Trim('\"') }
                    }
                }
            };

            var query = cfq.Query;

            query.ToNeo4jDriverParameters(bgc).IsEqualTo(expectedParameters).Should().BeTrue();
        }