Q: How to send strings/commands to stdin While testing programs it would be nice to be able to pump strings into stdin for processing (libvala-0.36 on VSCode 1.15.0-insider/Linux Mint 18.2). Below is just for illustration, but stdin.puts/stdin.flush doesn't seem to work. How can I pump keystrokes/strings into stdin?
 private void test_func(){
    ...do stuff
    stdin.puts("""{"event":"server.connected","params":{"version":"0.0.1","pid":0}}""");
    ...do stuff 
    stdin.puts("exit\r\n");
 }
 public static int main (string[] args) {
    string line;
    ...do stuff 

 #if DEBUG
    test_func();
 #endif

    while ((line = stdin.read_line ()) != null) {
       line = line.strip ();
       if (line.length > 0) {
          if (line == "exit") break;
          gJsonRPC.handle_request (line);
          }
       }
    ...do stuff 
    }

Update:
Have not found functionality similar to .Net "SendKeys" class in GLib, so temporarily settled on this method....
  public static void SendKeys(string sKeys) {
     //--------------------------------------------------------------
     //OSS:Hack:SendKeys
     //--------------------------------------------------------------
     char[] _keys = sKeys.to_utf8();
     for (int i = _keys.length; i >= 0; i--)
        stdin.ungetc (_keys[i]);
     //--------------------------------------------------------------
     }

@Lasall suggested FileStream.open(¨/dev/stdin¨, ¨w¨), so I try that next.

A: GLib.stdin really is just a GLib.FileStream.
You can encapsulate your processing code in a function that takes a FileStream like this:
public void my_processing_func (FileStream stream) {
   while ((line = stream.read_line ()) != null) {
      line = line.strip ();
      if (line.length > 0) {
         if (line == "exit") break;
         gJsonRPC.handle_request (line);
         }
      }
   }
}

Then in your main you can conditionally use either your test data or stdin:
#ifdef DEBUG
   var stream = test_func ();
#else
   var stream = stdin;
#endif
   my_processing_func (stream);

I probably wouldn't use DEBUG, but some more descriptive name like TEST_DATA, also it might be better to use proper unit testing and write a test program instead of #ifdefing your main program.
