public void ExecuteDoesNotThrowExceptionWhenInvokedWithNoEventSubscribers() { // Arrange var command = new OpenOptionsPage(); // Act, Assert Assert.DoesNotThrow(() => command.Execute(null)); }
public void CanExecuteReturnsTrue() { // Arrange var command = new OpenOptionsPage(); // 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 ExecuteRaisesOptionsPageRequested() { // Arrange var eventRaised = false; var handler = new EventHandler((s, e) => { eventRaised = true; }); var command = new OpenOptionsPage(); command.OptionsPageRequested += handler; // Act command.Execute(null); command.OptionsPageRequested -= handler; // Assert Assert.IsTrue(eventRaised); }
public void ShowOptionsPageIsInvokedOnExecutingOpenOptionsPageAfterInitializingServices() { // Arrange var openOptionsPage = new OpenOptionsPage(); var optionsPageService = Mock.Of <IOptionsPageService>(); var kernel = new MoqMockingKernel(); kernel.Bind <ICommand>().ToConstant(openOptionsPage); var package = new WorkingFilesWindowPackage(); package.InitializeServices(kernel, optionsPageService); // Act openOptionsPage.Execute(null); // Assert Mock.Get(optionsPageService).Verify(o => o.ShowOptionPage( typeof(OptionsPage))); }