コード例 #1
0
        public void CreateUpdateItem_CanUpdateOn_CausesUpdateToStartWhenClicked()
        {
            // Setup
            var commandHandler       = mocks.StrictMock <IApplicationFeatureCommands>();
            var importCommandHandler = mocks.StrictMock <IImportCommandHandler>();
            var exportCommandHandler = mocks.StrictMock <IExportCommandHandler>();
            var updateCommandHandler = mocks.StrictMock <IUpdateCommandHandler>();
            var viewCommands         = mocks.StrictMock <IViewCommands>();
            var nodeData             = new object();

            updateCommandHandler.Expect(ch => ch.CanUpdateOn(nodeData)).Return(true);
            updateCommandHandler.Expect(ch => ch.UpdateOn(nodeData));

            mocks.ReplayAll();

            var contextMenuFactory = new GuiContextMenuItemFactory(commandHandler,
                                                                   importCommandHandler,
                                                                   exportCommandHandler,
                                                                   updateCommandHandler,
                                                                   viewCommands,
                                                                   nodeData);

            ToolStripItem item = contextMenuFactory.CreateUpdateItem();

            // Call
            item.PerformClick();

            // Assert
            mocks.VerifyAll();
        }
コード例 #2
0
        public void CreateUpdateItem_Always_ItemWithPropertiesSet(bool canUpdateOn)
        {
            // Setup
            var commandHandler       = mocks.StrictMock <IApplicationFeatureCommands>();
            var importCommandHandler = mocks.StrictMock <IImportCommandHandler>();
            var exportCommandHandler = mocks.StrictMock <IExportCommandHandler>();
            var updateCommandHandler = mocks.StrictMock <IUpdateCommandHandler>();
            var viewCommands         = mocks.StrictMock <IViewCommands>();
            var nodeData             = new object();

            updateCommandHandler.Expect(ch => ch.CanUpdateOn(nodeData)).Return(canUpdateOn);

            mocks.ReplayAll();

            var contextMenuFactory = new GuiContextMenuItemFactory(commandHandler,
                                                                   importCommandHandler,
                                                                   exportCommandHandler,
                                                                   updateCommandHandler,
                                                                   viewCommands,
                                                                   nodeData);

            // Call
            ToolStripItem item = contextMenuFactory.CreateUpdateItem();

            // Assert
            Assert.AreEqual("&Bijwerken...", item.Text);
            Assert.AreEqual("Werk de geïmporteerde gegevens bij met nieuwe gegevens vanuit een bestand.", item.ToolTipText);
            TestHelper.AssertImagesAreEqual(Resources.RefreshIcon, item.Image);
            Assert.AreEqual(canUpdateOn, item.Enabled);

            mocks.VerifyAll();
        }