Ejemplo n.º 1
0
        public override Task StartInternalAsync()
        {
            _host = new RedisHost(Token, Settings.Port, new RedisEngine(Settings.Port));
            _host.Start();

            return(Task.Run(() => WaitHandle.WaitAll(new WaitHandle[] { Token.WaitHandle })));
        }
Ejemplo n.º 2
0
        public void RedisHost_ProcessStartsSuccessfully()
        {
            // Create a new Redis host, and ensure the process is running.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Process running.
            Assert.IsTrue(testHost.Running);

            // Make sure the port we've requested is actually open.
            bool portOpen = false;

            try
            {
                using (TcpClient tcpClient = new TcpClient())
                {
                    tcpClient.Connect("localhost", InstanceParams.DefaultPortNumber);
                    portOpen = true;
                }
            }
            catch { }

            // Port can be spoken to.
            Assert.IsTrue(portOpen);
        }
Ejemplo n.º 3
0
        public void RedisHost_ProcessTerminatesSuccessfully()
        {
            // Create a new Redis host, and ensure the process is running.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Dispose the host, and ensure that we've finished.
            testHost.Dispose();
            Assert.IsFalse(testHost.Running);
        }
Ejemplo n.º 4
0
        public void RedisHost_ReturnsAccessorWhileRunning()
        {
            // Build the test host.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Grab the accessor.
            var accessor = testHost.CreateAccessor();

            Assert.IsNotNull(accessor);
        }
Ejemplo n.º 5
0
        public void RedisHost_ReturnsNullAccessorWhileNotRunning()
        {
            // Build the test host.
            RedisHost testHost = new RedisHost();

            testHost.Start();

            // Kill the process.
            testHost.Dispose();

            // Grab the accessor.
            var accessor = testHost.CreateAccessor();

            Assert.IsNull(accessor);
        }