@@ -65,13 +65,48 @@ public async Task CouldResolve()
6565 vsServices . DidNotReceiveWithAnyArgs ( ) . ShowMessageBoxInfo ( null ) ;
6666 }
6767
68+ [ Test ]
69+ public async Task NoChangesInWorkingDirectory ( )
70+ {
71+ var gitHubContextService = Substitute . For < IGitHubContextService > ( ) ;
72+ var context = new GitHubContext ( ) ;
73+ var repositoryDir = "repositoryDir" ;
74+ var gitObject = ( "master" , "foo.cs" ) ;
75+ var vsServices = Substitute . For < IVSServices > ( ) ;
76+ var target = CreateOpenFromClipboardCommand ( gitHubContextService : gitHubContextService , vsServices : vsServices ,
77+ contextFromClipboard : context , repositoryDir : repositoryDir , gitObject : gitObject , hasChanges : false ) ;
78+
79+ await target . Execute ( null ) ;
80+
81+ vsServices . DidNotReceiveWithAnyArgs ( ) . ShowMessageBoxInfo ( null ) ;
82+ gitHubContextService . Received ( 1 ) . TryOpenFile ( repositoryDir , context ) ;
83+ }
84+
85+ [ Test ]
86+ public async Task HasChangesInWorkingDirectory ( )
87+ {
88+ var gitHubContextService = Substitute . For < IGitHubContextService > ( ) ;
89+ var context = new GitHubContext ( ) ;
90+ var repositoryDir = "repositoryDir" ;
91+ var gitObject = ( "master" , "foo.cs" ) ;
92+ var vsServices = Substitute . For < IVSServices > ( ) ;
93+ var target = CreateOpenFromClipboardCommand ( gitHubContextService : gitHubContextService , vsServices : vsServices ,
94+ contextFromClipboard : context , repositoryDir : repositoryDir , gitObject : gitObject , hasChanges : true ) ;
95+
96+ await target . Execute ( null ) ;
97+
98+ vsServices . Received ( 1 ) . ShowMessageBoxInfo ( OpenFromClipboardCommand . ChangesInWorkingDirectoryMessage ) ;
99+ gitHubContextService . Received ( 1 ) . TryOpenFile ( repositoryDir , context ) ;
100+ }
101+
68102 static OpenFromClipboardCommand CreateOpenFromClipboardCommand (
69103 IGitHubContextService gitHubContextService = null ,
70104 ITeamExplorerContext teamExplorerContext = null ,
71105 IVSServices vsServices = null ,
72106 GitHubContext contextFromClipboard = null ,
73107 string repositoryDir = null ,
74- ( string , string ) ? gitObject = null )
108+ ( string , string ) ? gitObject = null ,
109+ bool ? hasChanges = null )
75110 {
76111 var sp = Substitute . For < IServiceProvider > ( ) ;
77112 gitHubContextService = gitHubContextService ?? Substitute . For < IGitHubContextService > ( ) ;
@@ -85,6 +120,11 @@ static OpenFromClipboardCommand CreateOpenFromClipboardCommand(
85120 gitHubContextService . ResolveGitObject ( repositoryDir , contextFromClipboard ) . Returns ( gitObject . Value ) ;
86121 }
87122
123+ if ( hasChanges != null )
124+ {
125+ gitHubContextService . HasChangesInWorkingDirectory ( repositoryDir , gitObject . Value . Item1 , gitObject . Value . Item2 ) . Returns ( hasChanges . Value ) ;
126+ }
127+
88128 return new OpenFromClipboardCommand (
89129 new Lazy < IGitHubContextService > ( ( ) => gitHubContextService ) ,
90130 new Lazy < ITeamExplorerContext > ( ( ) => teamExplorerContext ) ,
0 commit comments