@@ -16,6 +16,7 @@ import { DataScienceCodeLensProvider } from '../../../client/datascience/editor-
1616import { CodeWatcher } from '../../../client/datascience/editor-integration/codewatcher' ;
1717import { ICodeWatcher , IHistory , IHistoryProvider } from '../../../client/datascience/types' ;
1818import { IServiceContainer } from '../../../client/ioc/types' ;
19+ import { ICodeExecutionHelper } from '../../../client/terminals/types' ;
1920import { MockAutoSelectionService } from '../../mocks/autoSelector' ;
2021import { createDocument } from './helpers' ;
2122
@@ -32,6 +33,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
3233 let fileSystem : TypeMoq . IMock < IFileSystem > ;
3334 let configService : TypeMoq . IMock < IConfigurationService > ;
3435 let serviceContainer : TypeMoq . IMock < IServiceContainer > ;
36+ let helper : TypeMoq . IMock < ICodeExecutionHelper > ;
3537 let tokenSource : CancellationTokenSource ;
3638 const pythonSettings = new class extends PythonSettings {
3739 public fireChangeEvent ( ) {
@@ -49,6 +51,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
4951 textEditor = TypeMoq . Mock . ofType < TextEditor > ( ) ;
5052 fileSystem = TypeMoq . Mock . ofType < IFileSystem > ( ) ;
5153 configService = TypeMoq . Mock . ofType < IConfigurationService > ( ) ;
54+ helper = TypeMoq . Mock . ofType < ICodeExecutionHelper > ( ) ;
5255
5356 // Setup default settings
5457 pythonSettings . datascience = {
@@ -77,7 +80,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
7780
7881 // Setup the service container to return code watchers
7982 serviceContainer = TypeMoq . Mock . ofType < IServiceContainer > ( ) ;
80- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( ICodeWatcher ) ) ) . returns ( ( ) => new CodeWatcher ( appShell . object , logger . object , historyProvider . object , fileSystem . object , configService . object , documentManager . object ) ) ;
83+ serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( ICodeWatcher ) ) ) . returns ( ( ) => new CodeWatcher ( appShell . object , logger . object , historyProvider . object , fileSystem . object , configService . object , documentManager . object , helper . object ) ) ;
8184
8285 // Setup our active history instance
8386 historyProvider . setup ( h => h . getOrCreateActive ( ) ) . returns ( ( ) => Promise . resolve ( activeHistory . object ) ) ;
@@ -91,7 +94,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
9194 // Setup config service
9295 configService . setup ( c => c . getSettings ( ) ) . returns ( ( ) => pythonSettings ) ;
9396
94- codeWatcher = new CodeWatcher ( appShell . object , logger . object , historyProvider . object , fileSystem . object , configService . object , documentManager . object ) ;
97+ codeWatcher = new CodeWatcher ( appShell . object , logger . object , historyProvider . object , fileSystem . object , configService . object , documentManager . object , helper . object ) ;
9598 } ) ;
9699
97100 function createTypeMoq < T > ( tag : string ) : TypeMoq . IMock < T > {
@@ -570,6 +573,10 @@ testing2`;
570573 const document = createDocument ( inputText , fileName , version , TypeMoq . Times . atLeastOnce ( ) ) ;
571574
572575 codeWatcher . setDocument ( document . object ) ;
576+ helper . setup ( h => h . getSelectedTextToExecute ( TypeMoq . It . is ( ( ed : TextEditor ) => {
577+ return textEditor . object === ed ;
578+ } ) ) ) . returns ( ( ) => Promise . resolve ( 'testing2' ) ) ;
579+ helper . setup ( h => h . normalizeLines ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => Promise . resolve ( 'testing2' ) ) ;
573580
574581 // Set up our expected calls to add code
575582 activeHistory . setup ( h => h . addCode ( TypeMoq . It . isValue ( 'testing2' ) ,
@@ -591,34 +598,6 @@ testing2`;
591598 document . verifyAll ( ) ;
592599 } ) ;
593600
594- test ( 'Test the RunCurrentCell command outside of a cell' , async ( ) => {
595- const fileName = 'test.py' ;
596- const version = 1 ;
597- const inputText =
598- `testing1
599- #%%
600- testing2` ;
601- const document = createDocument ( inputText , fileName , version , TypeMoq . Times . atLeastOnce ( ) ) ;
602-
603- codeWatcher . setDocument ( document . object ) ;
604-
605- // We don't want to ever call add code here
606- activeHistory . setup ( h => h . addCode ( TypeMoq . It . isAny ( ) ,
607- TypeMoq . It . isAny ( ) ,
608- TypeMoq . It . isAny ( ) ,
609- TypeMoq . It . isAny ( ) ) ) . verifiable ( TypeMoq . Times . never ( ) ) ;
610-
611- // For this test we need to set up a document selection point
612- textEditor . setup ( te => te . selection ) . returns ( ( ) => new Selection ( 0 , 0 , 0 , 0 ) ) ;
613-
614- // Try our RunCell command with the first selection point
615- await codeWatcher . runCurrentCell ( ) ;
616-
617- // Verify function calls
618- activeHistory . verifyAll ( ) ;
619- document . verifyAll ( ) ;
620- } ) ;
621-
622601 test ( 'Test the RunCellAndAdvance command with next cell' , async ( ) => {
623602 const fileName = 'test.py' ;
624603 const version = 1 ;
0 commit comments