예제 #1
0
            public void WritesRunMessageCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                writer.Write(new RunMessage("RETURN 1 AS num"));
                writer.Flush();

                mocks.VerifyResult("00 13 b2 10 8f 52 45 54 55 52 4e 20 31 20 41 53 20 6e 75 6d a0 00 00");
            }
예제 #2
0
            public void WritesAckFailureMessageCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                writer.Write(new AckFailureMessage());
                writer.Flush();

                mocks.VerifyResult("00 02 B0 0E 00 00");
            }
예제 #3
0
            public void WritesInitMessageCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                writer.Write(new InitMessage("a", new Dictionary <string, object>()));
                writer.Flush();

                mocks.VerifyResult("00 05 B2 01 81 61 A0 00 00");
            }
예제 #4
0
            public void WritesDiscardAllMessageCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                writer.Write(new DiscardAllMessage());
                writer.Flush();

                mocks.VerifyResult("00 02 B0 2F 00 00");
            }
예제 #5
0
        public void ShouldWriteToStreamWhenFlushed()
        {
            var stream = new MemoryStream();
            var writer = new BoltWriter(stream, CreatePackStreamFactory());

            writer.Write(new RunMessage("RETURN $x", new Dictionary <string, object> {
                { "x", 1L }
            }));

            writer.Flush();

            Assert.NotEmpty(stream.ToArray());
        }
예제 #6
0
        public void ShouldAppendEoMMarkerOnWrite()
        {
            var stream = new MemoryStream();
            var writer = new BoltWriter(stream, CreatePackStreamFactory());

            writer.Write(new RunMessage("RETURN $x", new Dictionary <string, object> {
                { "x", 1L }
            }));

            writer.Flush();

            stream.ToArray().Should().EndWith(new byte[] { 0x00, 0x00 });
        }
예제 #7
0
        public static byte[] GenerateBoltMessage(int paramBytesLength)
        {
            using (var data = new MemoryStream())
            {
                var boltWriter = new BoltWriter(data);
                boltWriter.Write(new RunMessage("RETUN {a}", new Dictionary <string, object>
                {
                    { "a", Enumerable.Repeat((byte)0, paramBytesLength).ToArray() }
                }));
                boltWriter.Flush();

                return(data.ToArray());
            }
        }
예제 #8
0
            public void WritesRunMessageWithBoolParamCorrectly(bool value, string expectedBytes)
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                var values = new Dictionary <string, object> {
                    { "value", value }
                };

                writer.Write(new RunMessage("", values));
                writer.Flush();

                mocks.VerifyResult(expectedBytes);
            }
예제 #9
0
            public void WritesRunMessageWithArrayParamCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                var values = new Dictionary <string, object> {
                    { "value", new[] { 1, 2 } }
                };

                writer.Write(new RunMessage("", values));
                writer.Flush();

                mocks.VerifyResult("00 0D B2 10 80 A1 85 76 61 6C 75 65 92 01 02 00 00");
            }
예제 #10
0
            public void WritesRunMessageWithDictionaryParamCorrectly()
            {
                var mocks  = new WriterTests.Mocks();
                var writer = new BoltWriter(mocks.OutputStream);

                var values = new Dictionary <string, object>
                {
                    { "value", new Dictionary <string, object> {
                          { "key1", 1 }, { "key2", 2 }
                      } }
                };

                writer.Write(new RunMessage("", values));
                writer.Flush();

                mocks.VerifyResult("00 17 B2 10 80 A1 85 76 61 6C 75 65 A2 84 6B 65 79 31 01 84 6B 65 79 32 02 00 00");
            }