@@ -260,8 +260,6 @@ public void ExcludeFileExcludesFile()
260
260
Assert . AreEqual ( 1 , vm . ExcludedChanges . Count ) ;
261
261
}
262
262
263
- // I need to figure out how to make this throw.
264
- [ Ignore ]
265
263
[ TestMethod ]
266
264
public void ChangesPresenter_WhenCommitFails_ActionFailedEventIsRaised ( )
267
265
{
@@ -278,6 +276,12 @@ public void ChangesPresenter_WhenCommitFails_ActionFailedEventIsRaised()
278
276
}
279
277
} ;
280
278
279
+ _providerMock . Setup ( p => p . Commit ( It . IsAny < string > ( ) ) )
280
+ . Throws (
281
+ new SourceControlException ( "A source control exception was thrown." ,
282
+ new LibGit2Sharp . LibGit2SharpException ( "With an inner libgit2sharp exception" ) )
283
+ ) ;
284
+
281
285
var wasRaised = false ;
282
286
283
287
vm . ErrorThrown += ( e , sender ) => wasRaised = true ;
@@ -288,5 +292,35 @@ public void ChangesPresenter_WhenCommitFails_ActionFailedEventIsRaised()
288
292
//assert
289
293
Assert . IsTrue ( wasRaised , "ActionFailedEvent was not raised." ) ;
290
294
}
295
+
296
+ [ TestMethod ]
297
+ public void UndoUndoesChanges ( )
298
+ {
299
+ //arrange
300
+ var fileStatusEntries = new List < FileStatusEntry >
301
+ {
302
+ new FileStatusEntry ( @"C:\path\to\module.bas" , FileStatus . Modified ) ,
303
+ new FileStatusEntry ( @"C:\path\to\class.cls" , FileStatus . Unaltered ) ,
304
+ new FileStatusEntry ( @"C:\path\to\added.bas" , FileStatus . Added | FileStatus . Modified ) ,
305
+ new FileStatusEntry ( @"C:\path\to\addedUnmodified.bas" , FileStatus . Added ) ,
306
+ new FileStatusEntry ( @"C:\path\to\untracked.frx" , FileStatus . Untracked )
307
+ } ;
308
+
309
+ var vm = new ChangesViewViewModel
310
+ {
311
+ Provider = _providerMock . Object
312
+ } ;
313
+
314
+ var localLocation = "C:\\ users\\ desktop\\ git\\ " ;
315
+
316
+ _providerMock . Setup ( git => git . Status ( ) ) . Returns ( fileStatusEntries ) ;
317
+ _providerMock . SetupGet ( git => git . CurrentRepository ) . Returns ( new Repository { LocalLocation = localLocation } ) ;
318
+
319
+ //act
320
+ vm . UndoChangesToolbarButtonCommand . Execute ( fileStatusEntries [ 0 ] ) ;
321
+
322
+ //Assert
323
+ _providerMock . Verify ( git => git . Undo ( localLocation + fileStatusEntries [ 0 ] . FilePath ) ) ;
324
+ }
291
325
}
292
326
}
0 commit comments