public void ExecuteDoesNotThrowExceptionWithNullParameter()
        {
            // Arrange

            var manager = Mock.Of <IDocumentMetadataManager>();
            var command = new ToggleIsPinned(manager);

            // Act, Assert

            Assert.DoesNotThrow(() => command.Execute(null));

            Mock.Get(manager).Verify(m =>
                                     m.TogglePinnedStatus(It.IsAny <DocumentMetadata>()),
                                     Times.Never);
        }
        public void CanExecuteReturnsTrue()
        {
            // Arrange

            var manager = Mock.Of <IDocumentMetadataManager>();
            var command = new ToggleIsPinned(manager);

            // Act

            var canExecute = command.CanExecute(null);

            // Assert

            Assert.IsTrue(canExecute);
        }
        public void AllCommandsAreAssigned()
        {
            // Arrange

            var activateWindow = new ActivateWindow(
                Mock.Of <DTE2>(),
                Mock.Of <IDocumentMetadataEqualityService>(),
                Mock.Of <IDocumentMetadataManager>(),
                Mock.Of <IProjectItemService>());

            var clearFilterString = new ClearFilterString(
                Mock.Of <IDocumentMetadataManager>());

            var closeDocument = new CloseDocument(
                Mock.Of <DTE2>(),
                Mock.Of <IDocumentMetadataEqualityService>());

            var openTestFile = new OpenTestFile(
                Mock.Of <IProjectItemService>(),
                Mock.Of <ITestFileNameEvaluator>());

            var openOptionsPage = new OpenOptionsPage();
            var toggleIsPinned  = new ToggleIsPinned(Mock.Of <IDocumentMetadataManager>());

            var commandList = new List <ICommand>
            {
                activateWindow,
                clearFilterString,
                closeDocument,
                openTestFile,
                openOptionsPage,
                toggleIsPinned
            };

            // Act

            var commands = new ToolWindowCommands(commandList);

            // Assert

            Assert.That(commands.ActivateWindow, Is.EqualTo(activateWindow));
            Assert.That(commands.ClearFilterString, Is.EqualTo(clearFilterString));
            Assert.That(commands.CloseDocument, Is.EqualTo(closeDocument));
            Assert.That(commands.OpenOptionsPage, Is.EqualTo(openOptionsPage));
            Assert.That(commands.OpenTestFile, Is.EqualTo(openTestFile));
            Assert.That(commands.ToggleIsPinned, Is.EqualTo(toggleIsPinned));
        }
        public void ExecuteInvokesDocumentMetadataManagerTogglePinnedStatus()
        {
            // Arrange

            var manager = Mock.Of <IDocumentMetadataManager>();
            var command = new ToggleIsPinned(manager);

            var metadata = new DocumentMetadata(
                new DocumentMetadataInfo(),
                string.Empty,
                null);

            // Act

            command.Execute(metadata);

            // Assert

            Mock.Get(manager).Verify(m =>
                                     m.TogglePinnedStatus(metadata),
                                     Times.Once);
        }