public void CanCreateXPathWriter(XPathFormat format, Type expectedXPathWriterType) { // Arrange var configuration = Substitute.For <IConfiguration>(); var factory = new XPathWriterFactory(() => configuration); // Act var writer = factory.CreateForXPathFormat(format); // Assert Assert.That(writer, Is.Not.Null.And.TypeOf(expectedXPathWriterType)); }
private static void RegisterDefaultServices(ServiceContainer serviceContainer) { var xmlRepository = new XmlRepository(); serviceContainer.Set(xmlRepository); var activeDocument = new ActiveDocument(); serviceContainer.Set(activeDocument); var writerFactory = new XPathWriterFactory(GetCurrentConfiguration); serviceContainer.Set(writerFactory); var searchResultFactory = new SearchResultFactory(activeDocument); serviceContainer.Set(searchResultFactory); ThreadHelper.ThrowIfNotOnUIThread(); var statusbarService = (IVsStatusbar)Package.GetGlobalService(typeof(IVsStatusbar)); serviceContainer.Set(new StatusbarAdapter(xmlRepository, GetCurrentStatusbarXPathWriter, statusbarService)); }
private void InitializeCommands(ActiveDocument activeDocument, XmlRepository repository, XPathWriterFactory writerFactory, IMenuCommandService commandService) { if (activeDocument == null) { throw new ArgumentNullException(nameof(activeDocument)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (commandService == null) { throw new ArgumentNullException(nameof(commandService)); } var subMenu = CreateSubMenu(activeDocument); commandService.AddCommand(subMenu); var copyGenericXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyGenericXPath, repository, activeDocument, () => writerFactory.CreateForCommandId(Symbols.CommandIDs.CopyGenericXPath), new CommandTextFormatter()); commandService.AddCommand(copyGenericXPathCommand); var copyAbsoluteXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyAbsoluteXPath, repository, activeDocument, () => writerFactory.CreateForCommandId(Symbols.CommandIDs.CopyAbsoluteXPath), new CommandTextFormatter()); commandService.AddCommand(copyAbsoluteXPathCommand); var copyDistinctXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyDistinctXPath, repository, activeDocument, () => writerFactory.CreateForCommandId(Symbols.CommandIDs.CopyDistinctXPath), new CommandTextFormatter()); commandService.AddCommand(copyDistinctXPathCommand); var copySimplifiedXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopySimplifiedXPath, repository, activeDocument, () => writerFactory.CreateForCommandId(Symbols.CommandIDs.CopySimplifiedXPath), new TrimCommandTextFormatter()); commandService.AddCommand(copySimplifiedXPathCommand); var showXPathWorkbenchCommand = new ShowXPathWorkbenchCommand(this, Symbols.CommandIDs.ShowXPathWorkbench, repository, activeDocument); commandService.AddCommand(showXPathWorkbenchCommand.Command); var copyXmlStructureCommand = new CopyXmlStructureCommand(Symbols.CommandIDs.CopyXmlStructure, repository, activeDocument, () => new XmlStructureWriter(), new CommandTextFormatter()); commandService.AddCommand(copyXmlStructureCommand); }