Esempio n. 1
0
        public async Task FahClientConnection_CloseConnectionWhileExecutingReaderAsynchronously()
        {
            using (var connection = new FahClientConnection(Host, Port))
            {
                await connection.OpenAsync();

                CloseConnectionAfter(3000, connection);

                var command = connection.CreateCommand();
                command.CommandText = "info";
                await command.ExecuteAsync();

                command.CommandText = "log-updates restart";
                await command.ExecuteAsync();

                var reader = connection.CreateReader();
                try
                {
                    while (await reader.ReadAsync())
                    {
                        Console.WriteLine(reader.Message);
                    }
                }
                catch (Exception ex)
                {
                    Assert.IsFalse(connection.Connected);
                    Console.WriteLine(ex);
                }
            }
        }
Esempio n. 2
0
        public async Task FahClientConnection_WritesCommandsAndReadsMessageAsynchronously()
        {
            using (var connection = new FahClientConnection(Host, Port))
            {
                await connection.OpenAsync();

                var command = connection.CreateCommand();
                command.CommandText = "info";
                await command.ExecuteAsync();

                var reader = connection.CreateReader();
                if (await reader.ReadAsync())
                {
                    Console.WriteLine(reader.Message);
                }

                command.CommandText = "log-updates restart";
                await command.ExecuteAsync();

                if (await reader.ReadAsync())
                {
                    Console.WriteLine(reader.Message);
                }
            }
        }
Esempio n. 3
0
 public void FahClientConnection_CreateReaderReturnsReaderWhenNotConnected()
 {
     // Arrange
     using (var connection = new FahClientConnection("foo", 2000))
     {
         // Act
         var reader = connection.CreateReader();
         // Assert
         Assert.IsNotNull(reader);
     }
 }
Esempio n. 4
0
        public void FahClientConnection_SimulateHFMUpdateCommandsSynchronously()
        {
            using (var connection = new FahClientConnection(Host, Port))
            {
                connection.Open();

                connection.CreateCommand("log-updates restart").Execute();
                connection.CreateCommand("updates add 0 60 $heartbeat").Execute();
                connection.CreateCommand("updates add 1 1 $info").Execute();
                connection.CreateCommand("updates add 2 1 $(options -a)").Execute();
                connection.CreateCommand("updates add 3 1 $slot-info").Execute();

                var reader = connection.CreateReader();
                for (int i = 0; i < 10 && reader.Read(); i++)
                {
                    Console.WriteLine(reader.Message);
                }
            }
        }
Esempio n. 5
0
        public void FahClientConnection_WritesCommandsAndReadsMessageSynchronously()
        {
            using (var connection = new FahClientConnection(Host, Port))
            {
                connection.Open();

                var command = connection.CreateCommand();
                command.CommandText = "info";
                command.Execute();

                var reader = connection.CreateReader();
                if (reader.Read())
                {
                    Console.WriteLine(reader.Message);
                }

                command.CommandText = "log-updates restart";
                command.Execute();
                if (reader.Read())
                {
                    Console.WriteLine(reader.Message);
                }
            }
        }