Beispiel #1
0
        public void PerformFilter_Test_FiltersApplied()
        {
            // arrange
            // view
            var fakeView = A.Fake <IMainWindow>();

            fakeView.CategoryDropDownSelectedIndex = 0;
            A.CallTo(() => fakeView.TitleFilterText).Returns("book 2");
            A.CallTo(() => fakeView.SelectedFilterTags).Returns(new List <string> {
                "tag2"
            });
            // repos
            var       fakeBookRepo = A.Fake <IBookService>();
            DataTable allItems     = new DataTable();

            allItems.Columns.Add("Id");
            allItems.Columns.Add("Title");
            allItems.Columns.Add("Tags");
            allItems.Rows.Add(
                1,
                "book 1",
                "tag1"
                );
            allItems.Rows.Add(
                2,
                "book 2",
                "tag2"
                );
            allItems.Rows.Add(
                3,
                "third book",
                "tag2"
                );
            var fakeMediaItemService = A.Fake <IMediaItemService>();
            // presenter
            var fakeTagService          = A.Fake <ITagService>();
            var fakeAuthorService       = A.Fake <IAuthorService>();
            var fakePublisherService    = A.Fake <IPublisherService>();
            MockItemPresenter presenter = new MockItemPresenter(fakeBookRepo, fakeMediaItemService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView,
                                                                allItems);

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

            // assert
            Assert.IsTrue(fakeView.DisplayedItems.Rows.Count == 1);
            Assert.AreEqual("book 2", fakeView.DisplayedItems.Rows[0].ItemArray[1].ToString());
        }
Beispiel #2
0
        public void PerformFilter_Test_NoFilters()
        {
            // arrange
            // view
            var fakeView = A.Fake <IMainWindow>();

            fakeView.CategoryDropDownSelectedIndex = 0;
            A.CallTo(() => fakeView.TitleFilterText).Returns("");
            // repos
            var       fakeBookRepo = A.Fake <IBookService>();
            DataTable allItems     = new DataTable();

            allItems.Columns.Add("Id");
            allItems.Columns.Add("Title");
            allItems.Rows.Add(
                1,
                "book 1"
                );
            allItems.Rows.Add(
                2,
                "book 2"
                );
            var fakeMediaItemService = A.Fake <IMediaItemService>();
            // presenter
            var fakeTagService          = A.Fake <ITagService>();
            var fakeAuthorService       = A.Fake <IAuthorService>();
            var fakePublisherService    = A.Fake <IPublisherService>();
            MockItemPresenter presenter = new MockItemPresenter(fakeBookRepo, fakeMediaItemService, fakeTagService, fakeAuthorService, fakePublisherService, fakeView,
                                                                allItems);

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

            // assert
            Assert.IsTrue(fakeView.DisplayedItems.Rows.Count == 2);
        }