Exemplo n.º 1
0
        public void OnTeamCollectionBookStatusChange_TeamCollection_GivenCheckedOutByOther_WhenCheckedOutByNone_RemovesIcon()
        {
            // Setup //
            var collectionFolder = new TemporaryFolder("LibraryListViewTests");

            Book.BookCollectionTests.AddBook(collectionFolder, "book1");

            _view = new LibraryListView(new FakeLibraryModel(collectionFolder), new BookSelection(), new SelectedTabChangedEvent(), new LocalizationChangedEvent(), new BookStatusChangeEvent(), null);

            var primaryCollectionFlow = new FlowLayoutPanel();
            var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view);

            obj.SetField("_primaryCollectionFlow", primaryCollectionFlow);
            _view.LoadPrimaryCollectionButtons();
            _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.Other));
            var button = primaryCollectionFlow.Controls.OfType <Button>().First();

            Assert.AreEqual(1, button.Controls.OfType <Label>().Count(), "Test was not set up properly. Wrong number of labels.");

            // System Under Test //
            _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.None));

            // Verification //
            var labelOfButton = button.Controls.OfType <Label>().FirstOrDefault();

            Assert.IsNull(labelOfButton);
        }
Exemplo n.º 2
0
        public void OnTeamCollectionBookStatusChange_TeamCollection_CheckedOutBySelf()
        {
            // Setup //
            var collectionFolder = new TemporaryFolder("LibraryListViewTests");

            Book.BookCollectionTests.AddBook(collectionFolder, "book1");

            _view = new LibraryListView(new FakeLibraryModel(collectionFolder), new BookSelection(), new SelectedTabChangedEvent(), new LocalizationChangedEvent(), new BookStatusChangeEvent(), null);

            var primaryCollectionFlow = new FlowLayoutPanel();
            var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view);

            obj.SetField("_primaryCollectionFlow", primaryCollectionFlow);
            _view.LoadPrimaryCollectionButtons();

            // System Under Test //
            _view.OnTeamCollectionBookStatusChange(new BookStatusChangeEventArgs("book1", CheckedOutBy.Self));

            // Verification //
            var button        = primaryCollectionFlow.Controls.OfType <Button>().First();
            var labelOfButton = button.Controls.OfType <Label>().First();

            AssertImageCenterIsColor(labelOfButton.Image, Palette.BloomYellow);
        }