public void RaiseNewCatchedExceptionEventAtInstantiate() { ExceptionEventCatcher catcher = new ExceptionEventCatcher(); BaseException exception = new FakeBaseException(); Assert.IsTrue(catcher.ExceptionEventInvoked); Assert.AreEqual(exception, catcher.Exception); }
public void IfPlaySongReturnsAnExceptionCatchIt() { ExceptionEventCatcher catcher = new ExceptionEventCatcher(); MediaFile file = Create.MediaFile(); Song songToPlay = Create.Song(file); PlayerViewModel viewModel = new PlayerViewModel(); MockService.Setup(s => s.GetMediaFileById(songToPlay.MediaFileId)).Returns(file); MockMusicPlayer.Setup(mp => mp.Play(file.Id, file.Content)).Throws<Exception>(); PlayerObserver.NotifyPlayNewSong(songToPlay); Assert.IsTrue(catcher.ExceptionEventInvoked); Assert.IsTrue(catcher.Exception is PlayException); }