public void OperationUpdatesSessionStatus([TestConfigurations] ServerConfiguration config)
 {
     using (ServerContext context = new ServerContext(config))
     {
         using (var connection = context.OpenRdpConnection())
         {
             context.Source.Disconnect(context.TargetConnection, connection.SessionId);
             Assert.That(context.Source.GetSessionState(context.TargetConnection, connection.SessionId),
                         Is.EqualTo(ConnectionState.Disconnected));
         }
     }
 }
Пример #2
0
 public void OperationClosesSession([TestConfigurations] ServerConfiguration config)
 {
     using (var context = new ServerContext(config))
     {
         using (var connection = context.OpenRdpConnection())
         {
             context.Source.Logoff(context.TargetConnection, connection.SessionId);
             // Give Windows a bit of time to clean up the session.
             Thread.Sleep(1000);
             Assert.That(context.Source.SessionExists(context.TargetConnection, connection.SessionId), Is.False);
         }
     }
 }
 public void OperationDisconnectsClient([TestConfigurations] ServerConfiguration config)
 {
     using (var context = new ServerContext(config))
     {
         using (var connection = context.OpenRdpConnection())
         {
             var disconnectEvent = new ManualResetEvent(false);
             connection.Disconnected += delegate { disconnectEvent.Set(); };
             context.Source.Disconnect(context.TargetConnection, connection.SessionId);
             if (!disconnectEvent.WaitOne(TimeSpan.FromSeconds(10)))
             {
                 throw new TimeoutException("Not disconnected yet");
             }
         }
     }
 }
 public void ShowMessageBoxAndGetResponse([TestConfigurations] ServerConfiguration config)
 {
     using (var context = new ServerContext(config))
     {
         using (var connection = context.OpenRdpConnection())
         {
             var title = "Test " + Guid.NewGuid();
             context.Source.StartShowingMessageBox(context.TargetConnection, connection.SessionId, title,
                                                   "Hello!", RemoteMessageBoxButtons.AbortRetryIgnore,
                                                   TimeSpan.Zero);
             Assert.That(context.Target.WindowWithTitleExists(connection.SessionId, title));
             const RemoteMessageBoxResult expected = RemoteMessageBoxResult.Retry;
             // The automation ID of the button in the window is 4.
             context.Target.ClickButtonInWindow(connection.SessionId, title, ((int) expected).ToString());
             Assert.That(context.Source.GetLatestMessageBoxResponse(), Is.EqualTo(expected));
         }
     }
 }