Exemplo n.º 1
0
 private static void AssertCopyToInteractive(ExportProvider exportProvider, string code, string expectedBufferText, string submissionBuffer = null)
 {
     using var workspace = InteractiveWindowCommandHandlerTestState.CreateTestState(exportProvider, code);
     PrepareSubmissionBuffer(submissionBuffer, workspace);
     workspace.SendCopyToInteractive();
     Assert.Equal(expectedBufferText, workspace.WindowCurrentLanguageBuffer.CurrentSnapshot.GetText());
 }
Exemplo n.º 2
0
 private static void PrepareSubmissionBuffer(string submissionBuffer, InteractiveWindowCommandHandlerTestState workspace)
 {
     if (!string.IsNullOrEmpty(submissionBuffer))
     {
         workspace.WindowCurrentLanguageBuffer.Insert(0, submissionBuffer);
     }
 }
Exemplo n.º 3
0
 private static void AssertUnavailableExecuteInInteractive(string code)
 {
     using (var workspace = InteractiveWindowCommandHandlerTestState.CreateTestState(code))
     {
         Assert.Equal(CommandState.Unavailable, workspace.GetStateForExecuteInInteractive());
     }
 }
Exemplo n.º 4
0
 private static void AssertUnavailableCopyToInteractive(string code, string submissionBuffer = null)
 {
     using (var workspace = InteractiveWindowCommandHandlerTestState.CreateTestState(code))
     {
         PrepareSubmissionBuffer(submissionBuffer, workspace);
         Assert.Equal(CommandState.Unavailable, workspace.GetStateForCopyToInteractive());
     }
 }
Exemplo n.º 5
0
        private static void AssertExecuteInInteractive(string code, string[] expectedSubmissions, string submissionBuffer = null)
        {
            List <string>         submissions      = new List <string>();
            EventHandler <string> appendSubmission = (_, item) => { submissions.Add(item.TrimEnd()); };

            using (var workspace = InteractiveWindowCommandHandlerTestState.CreateTestState(code))
            {
                PrepareSubmissionBuffer(submissionBuffer, workspace);
                Assert.Equal(CommandState.Available, workspace.GetStateForExecuteInInteractive());

                workspace.Evaluator.OnExecute += appendSubmission;
                workspace.ExecuteInInteractive();
                AssertEx.Equal(expectedSubmissions, submissions);
            }
        }
Exemplo n.º 6
0
        private static void AssertExecuteInInteractive(ExportProvider exportProvider, string code, string[] expectedSubmissions, string submissionBuffer = null)
        {
            var submissions = new List <string>();

            void appendSubmission(object _, string item)
            {
                submissions.Add(item.TrimEnd());
            }

            using var workspace = InteractiveWindowCommandHandlerTestState.CreateTestState(exportProvider, code);
            PrepareSubmissionBuffer(submissionBuffer, workspace);
            Assert.Equal(CommandState.Available, workspace.GetStateForExecuteInInteractive());

            workspace.Evaluator.OnExecute += appendSubmission;
            workspace.ExecuteInInteractive();
            AssertEx.Equal(expectedSubmissions, submissions);
        }
        private static void PrepareSubmissionBuffer(string submissionBuffer, InteractiveWindowCommandHandlerTestState workspace)
        {
            if (string.IsNullOrEmpty(submissionBuffer))
            {
                return;
            }

            workspace.WindowCurrentLanguageBuffer.Insert(0, submissionBuffer);
        }