Exemple #1
0
        public void HandleAddNewTagClicked_Test_NoEntry()
        {
            // arrange
            var fakeView = A.Fake <IAddBookForm>();

            A.CallTo(() => fakeView.ShowNewTagDialog()).Returns("");
            var fakeBookService         = A.Fake <IBookService>();
            var fakeTagService          = A.Fake <ITagService>();
            var fakeImageFileReader     = A.Fake <IImageFileReader>();
            var fakeAuthorService       = A.Fake <IAuthorService>();
            var fakePublisherService    = A.Fake <IPublisherService>();
            MockBookPresenter presenter = new MockBookPresenter(fakeBookService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView, fakeImageFileReader);

            // act
            presenter.HandleAddNewTagClicked(null, null);

            // assert
            A.CallTo(() => fakeView.ShowTagAlreadyExistsDialog("")).MustNotHaveHappened();
        }
Exemple #2
0
        public void HandleAddNewTagClicked_Test_TagDoesNotYetExist()
        {
            // arrange
            var fakeView = A.Fake <IAddBookForm>();

            A.CallTo(() => fakeView.ShowNewTagDialog()).Returns("tag2");
            var fakeBookService                 = A.Fake <IBookService>();
            var fakeTagService                  = A.Fake <ITagService>();
            var fakeImageFileReader             = A.Fake <IImageFileReader>();
            var fakeAuthorService               = A.Fake <IAuthorService>();
            var fakePublisherService            = A.Fake <IPublisherService>();
            MockBookPresenter         presenter = new MockBookPresenter(fakeBookService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView, fakeImageFileReader);
            Dictionary <string, bool> allTags   = new Dictionary <string, bool>();

            allTags.Add("tag1", true);
            presenter.SetAllTags(allTags);

            // act
            presenter.HandleAddNewTagClicked(null, null);

            // assert
            Assert.IsTrue(presenter.GetAllTagsValueByKey("tag2"));
        }