Beispiel #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);
        }
Beispiel #2
0
        public void LoadPrimaryCollectionButtons_BookTitleHasAmpersand_ButtonUsesNonEscapedForm()
        {
            // Setup //
            var collectionFolder = new TemporaryFolder("LibraryListViewTests");

            Book.BookCollectionTests.AddBook(collectionFolder, "A&B Book");

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

            // System Under Test //
            _view.LoadPrimaryCollectionButtons();

            // Verification //
            var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view);
            var primaryCollectionFlow = (FlowLayoutPanel)(obj.GetFieldOrProperty("_primaryCollectionFlow"));
            var firstBookButton       = primaryCollectionFlow.Controls.OfType <Button>().First();

            Assert.AreEqual("A&B Book", firstBookButton.Text, "Text");                  // Not escaped because the button has UseMnemonic = false
            Assert.AreEqual(false, firstBookButton.UseMnemonic, "UseMnemonic");
        }
Beispiel #3
0
        public void LoadPrimaryCollectionButtons_CollectionNameHasAmpersand_IsEscaped()
        {
            // Setup //
            var collectionFolder          = new TemporaryFolder("LibraryListViewTests");
            var collectionSettings        = new CollectionSettings();
            var privateCollectionSettings = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(collectionSettings);

            privateCollectionSettings.SetFieldOrProperty("CollectionName", "A&B");

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

            // System Under Test //
            _view.LoadPrimaryCollectionButtons();

            // Verification //
            var obj = new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(_view);
            var primaryCollectionFlow = (FlowLayoutPanel)(obj.GetFieldOrProperty("_primaryCollectionFlow"));
            var listHeader            = primaryCollectionFlow.Controls.OfType <ListHeader>().First();

            Assert.AreEqual("A&&B", listHeader.Label.Text);
        }
Beispiel #4
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);
        }