예제 #1
0
        public void IgnoresExistingProcedures()
        {
            var bydigest = new Dictionary <String, ProcedureDefinition>
            {
                { "digest1", new ProcedureDefinition()
                  {
                      Body = "digestBody1"
                  } },
                { "digest2", new ProcedureDefinition()
                  {
                      Body = "digestBody2"
                  } }
            };
            var byalias = new Dictionary <String, ProcedureDefinition>();

            var procedures     = new ProcedureCollection(byalias, bydigest);
            var initializer    = new ProcedureInitializer(procedures, NoLogger.Instance);
            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader("*2\r\n:1\r\n:1\r\n");
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
            writer.Flush();
            writtingStream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual("*4\r\n$6\r\nSCRIPT\r\n$6\r\nexists\r\n$7\r\ndigest1\r\n$7\r\ndigest2\r\n", new StreamReader(writtingStream).ReadToEnd());
        }
        public void IgnoresNoInitialization()
        {
            var initializer = new ConnectionInitializer(new RedisClientOptions());

            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader(null);
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
        }
        public void DetectMissingResponseErrors()
        {
            var options = new RedisClientOptions();

            options.InitializationCommands.Add(new PreInitializationCommand("auth vtortola"));
            var initializer = new ConnectionInitializer(options);

            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader(null);
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
        }
예제 #4
0
        public void CanCreateCommand()
        {
            var command = new RESPCommand(new RESPCommandLiteral("Hello"), false);

            command.Add(new RESPCommandLiteral("World"));
            command.Add(new RESPCommandLiteral("1"));

            var target = new DummySocketWriter(new MemoryStream());

            command.WriteTo(target);

            Assert.AreEqual(3, command.Count);
            Assert.AreEqual("*3\r\n$5\r\nHello\r\n$5\r\nWorld\r\n$1\r\n1\r\n", target.ToString());
        }
예제 #5
0
        public void IgnoresNoInitialization()
        {
            var procedures     = new ProcedureCollection();
            var initializer    = new ProcedureInitializer(procedures, NoLogger.Instance);
            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader(null);
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);
            writer.Flush();
            writtingStream.Seek(0, SeekOrigin.Begin);

            Assert.AreEqual(0, writtingStream.Position);
        }
        public void InitializesWithCommands()
        {
            var options = new RedisClientOptions();

            options.InitializationCommands.Add(new PreInitializationCommand("auth vtortola"));
            var initializer = new ConnectionInitializer(options);

            var writtingStream = new MemoryStream();
            var reader         = new DummySocketReader("+OK\r\n");
            var writer         = new DummySocketWriter(writtingStream);

            initializer.Initialize(reader, writer);

            writtingStream.Seek(0, SeekOrigin.Begin);
            Assert.AreEqual("*2\r\n$4\r\nAUTH\r\n$8\r\nvtortola\r\n", new StreamReader(writtingStream).ReadToEnd());
        }