Exemplo n.º 1
0
        public void CanOpenViewFor_HasViewInfoDefinedForData_ReturnTrue(int numberOfViewDefinitions)
        {
            // Setup
            var viewObject = new object();

            var viewInfos = new ViewInfo[numberOfViewDefinitions];

            for (var i = 0; i < viewInfos.Length; i++)
            {
                viewInfos[i] = new ViewInfo();
            }

            var mocks = new MockRepository();
            var documentViewController = mocks.Stub <IDocumentViewController>();

            documentViewController.Expect(r => r.GetViewInfosFor(viewObject)).Return(viewInfos);
            var viewController = mocks.Stub <IViewController>();

            viewController.Stub(c => c.DocumentViewController).Return(documentViewController);
            var applicationSelection = mocks.Stub <IApplicationSelection>();
            var pluginsHost          = mocks.Stub <IPluginsHost>();

            mocks.ReplayAll();

            var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost);

            // Call
            bool hasViewDefinitionsForData = commandHandler.CanOpenViewFor(viewObject);

            // Assert
            Assert.IsTrue(hasViewDefinitionsForData);
            mocks.VerifyAll();
        }
Exemplo n.º 2
0
        public void CanOpenViewFor_NoViewInfosForTarget_ReturnFalse()
        {
            // Setup
            var viewObject = new object();

            var viewInfos = new ViewInfo[0];

            var mocks = new MockRepository();
            var documentViewController = mocks.Stub <IDocumentViewController>();

            documentViewController.Expect(r => r.GetViewInfosFor(viewObject)).Return(viewInfos);
            var viewController = mocks.Stub <IViewController>();

            viewController.Stub(c => c.DocumentViewController).Return(documentViewController);
            var applicationSelection = mocks.Stub <IApplicationSelection>();
            var pluginsHost          = mocks.Stub <IPluginsHost>();

            mocks.ReplayAll();

            var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost);

            // Call
            bool hasViewDefinitionsForData = commandHandler.CanOpenViewFor(viewObject);

            // Assert
            Assert.IsFalse(hasViewDefinitionsForData);
            mocks.VerifyAll();
        }