public async Task DeleteButtonClicked_Test_MediaItem() { // arrange var fakeBookRepo = A.Fake <IBookService>(); var fakeMediaItemService = A.Fake <IMediaItemService>(); var fakeTagService = A.Fake <ITagService>(); var fakeAuthorService = A.Fake <IAuthorService>(); var fakePublisherService = A.Fake <IPublisherService>(); var fakeView = A.Fake <IMainWindow>(); A.CallTo(() => fakeView.CategoryDropDownSelectedIndex).Returns(1); MainWindowPresenter presenter = new MainWindowPresenter(fakeBookRepo, fakeMediaItemService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView); // act await presenter.HandleDeleteButtonClicked(null, null); // assert A.CallTo(() => fakeMediaItemService.DeleteById(fakeView.SelectedItemId)).MustHaveHappened(); }
public async Task DeleteButtonClicked_Test_Book_Error() { // arrange var fakeBookRepo = A.Fake <IBookService>(); var fakeMediaItemService = A.Fake <IMediaItemService>(); var fakeTagService = A.Fake <ITagService>(); var fakeAuthorService = A.Fake <IAuthorService>(); var fakePublisherService = A.Fake <IPublisherService>(); var fakeView = A.Fake <IMainWindow>(); A.CallTo(() => fakeView.CategoryDropDownSelectedIndex).Returns(0); A.CallTo(() => fakeBookRepo.DeleteById(fakeView.SelectedItemId)).Throws(new Exception("error")); MainWindowPresenter presenter = new MainWindowPresenter(fakeBookRepo, fakeMediaItemService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView); // act await presenter.HandleDeleteButtonClicked(null, null); // assert A.CallTo(() => fakeBookRepo.DeleteById(fakeView.SelectedItemId)).MustHaveHappened(); A.CallTo(() => fakeView.ShowErrorDialog("Error deleting item.", "error")).MustHaveHappened(); }