/// <summary> /// Sets up tree node properties accordingly to feature node properties. /// </summary> /// <param name="node"></param> /// <param name="treeNode"></param> void TransmitProperties(FeatureNode node, TreeNode treeNode) { System.Diagnostics.Debug.WriteLine(string.Format("Set properties for {0} node. Selected: {1}", node.DisplayName, node.Checked)); treeNode.Checked = node.Checked; HighlightNode(treeNode, node.Enabled); treeNode.ImageKey = node.State.ToString(); treeNode.SelectedImageKey = treeNode.ImageKey; switch (node.State) { case FeatureState.Mandatory: treeNode.ToolTipText = MANDATORYFEATURE; break; case FeatureState.Optional: treeNode.ToolTipText = OPTIONALFEATURE; break; case FeatureState.Undefined: treeNode.ToolTipText = DISABLEDFEATURE; break; } }
public static FeaturesSet CreateFeaturesSet() { FeaturesSet featuresSet = new FeaturesSet(); foreach (Feature group in FeatureHelper.GetFeaturesWithType(NodeType.Parent)) { FeatureNode groupNode = new FeatureNode { Name = group.GetDisplayName(), Feature = group, State = FeatureState.Undefined, Type = NodeType.Parent }; foreach (Feature feature in group.GetChildFeatures()) { groupNode.Nodes.Add(new FeatureNode { Name = feature.GetDisplayName(), Feature = feature, State = FeatureState.Undefined, Type = NodeType.Feature }); } featuresSet.Nodes.Add(groupNode); } return(featuresSet); }
/// <summary> /// Adds feature node with subnodes. /// </summary> /// <param name="parent"></param> /// <param name="node"></param> void AddFeatureNode(TreeNode parent, FeatureNode node) { TreeNode treeNode = new TreeNode(node.DisplayName); treeNode.Tag = node; treeNode.Name = node.Name; TransmitProperties(node, treeNode); if (parent != null) { parent.Nodes.Add(treeNode); } else { tvFeatures.Nodes.Add(treeNode); } if (node.Feature != Feature.None) { _featureNodes.Add(node.Feature, treeNode); } foreach (FeatureNode child in node.Nodes) { AddFeatureNode(treeNode, child); } }
private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults) { foreach (var featureElement in featureTreeNode.Feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { featureElement.Result = testResults.GetScenarioResult(scenario); continue; } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { foreach (var example in scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows)) { example.Result = testResults.GetExampleResult(scenarioOutline, example.Cells.ToArray()); } scenarioOutline.Result = scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows) .Select(row => row.Result) .Merge(); } } }
public void GivenIHaveAFeatureCalled(string p0) { var newFeature = new Feature(); newFeature.Name = p0; var relPath = "fakedir"; var location = FileSystem.FileInfo.FromFileName(@"c:\"); INode newNode = new FeatureNode(location, relPath, newFeature); Tree featureTree = null; if (ScenarioContext.Current.ContainsKey("Feature Tree")) { featureTree = (Tree)ScenarioContext.Current["Feature Tree"]; } else { INode rootNode = new FolderNode(location, relPath); featureTree = new Tree(rootNode); } featureTree.Add(newNode); ScenarioContext.Current["Feature Tree"] = featureTree; }
public XDocument Format(FeatureNode featureNode, GeneralTree<FeatureNode> features) { var xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml"); var featureNodeOutputPath = Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot); var featureNodeOutputUri = new Uri(featureNodeOutputPath); var container = new XElement(xmlns + "div", new XAttribute("id", "container")); container.Add(this.htmlHeaderFormatter.Format()); container.Add(this.htmlTableOfContentsFormatter.Format(featureNode.Url, features)); container.Add(this.htmlContentFormatter.Format(featureNode)); container.Add(this.htmlFooterFormatter.Format()); var body = new XElement(xmlns + "body"); body.Add(container); var head = new XElement(xmlns + "head"); head.Add(new XElement(xmlns + "title", string.Format("{0}", featureNode.Name))); head.Add(new XElement(xmlns + "link", new XAttribute("rel", "stylesheet"), new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.MasterStylesheet)), new XAttribute("type", "text/css"))); var html = new XElement(xmlns + "html", new XAttribute(XNamespace.Xml + "lang", "en"), head, body); var document = new XDocument( new XDeclaration("1.0", "UTF-8", null), new XDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", string.Empty), html); return document; }
/// <summary> /// Adds feature node with subnodes. /// </summary> /// <param name="parent"></param> /// <param name="node"></param> void AddFeatureNode(TreeNode parent, FeatureNode node) { TreeNode treeNode = new TreeNode(node.DisplayName); treeNode.Tag = node; treeNode.Name = node.Name; if (node.Status != FeatureStatus.Group) { ClearNode(treeNode); _featureNodes.Add(node.Feature, treeNode); } else { treeNode.ImageKey = "Group"; treeNode.SelectedImageKey = treeNode.ImageKey; } if (parent != null) { parent.Nodes.Add(treeNode); } else { tvFeatures.Nodes.Add(treeNode); } foreach (FeatureNode child in node.Nodes) { AddFeatureNode(treeNode, child); } }
/// <summary> /// Initializes display name. /// </summary> /// <param name="node"></param> static void Translate(FeatureNode node) { node.DisplayName = GetTreeDisplayName(node.Feature); foreach (FeatureNode child in node.Nodes) { Translate(child); } }
public JsonFeatureWithMetaInfo(FeatureNode featureNodeTreeNode, ILanguageServicesRegistry languageServicesRegistry, TestResult result) { var jsonMapper = new JsonMapper(languageServicesRegistry); this.Feature = jsonMapper.Map(featureNodeTreeNode.Feature); this.RelativeFolder = featureNodeTreeNode.RelativePathFromRoot; this.Result = jsonMapper.Map(result); }
public JsonFeatureWithMetaInfo(FeatureNode featureNodeTreeNode, TestResult result) { var jsonMapper = new JsonMapper(); this.Feature = jsonMapper.Map(featureNodeTreeNode.Feature); this.RelativeFolder = featureNodeTreeNode.RelativePathFromRoot; this.Result = jsonMapper.Map(result); }
private Lines Feature(FeatureNode node) { var feature = node.Feature; var featureBlock = new FeatureBlock(feature, style); return(featureBlock.Lines); }
/// <summary> /// Sets up child features /// </summary> /// <param name="node"></param> void SetupChildFeatures(FeatureNode node) { foreach (FeatureNode child in node.Nodes) { TreeNode treeNode = _featureNodes[child.Feature]; TransmitProperties(child, treeNode); SetupChildFeatures(child); } }
private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults) { foreach (var scenario in featureTreeNode.Feature.FeatureElements) { scenario.Result = scenario.GetType().Name == "Scenario" ? testResults.GetScenarioResult(scenario as Scenario) : testResults.GetScenarioOutlineResult(scenario as ScenarioOutline); } }
public void Format(FeatureNode featureNode) { Feature feature = featureNode.Feature; var topic = new XElement("topic", new XAttribute("id", feature.Name.ToDitaName())); topic.Add(new XElement("title", feature.Name)); topic.Add(new XElement("shortdesc", feature.Description)); var body = new XElement("body"); topic.Add(body); if (this.configuration.HasTestResults) { TestResult testResult = this.nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.Add(new XElement("note", "This feature passed")); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.Add(new XElement("note", "This feature failed")); } } foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { this.ditaScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.ditaScenarioOutlineFormatter.Format(body, scenarioOutline); } } // HACK - This relative path stuff needs to be refactored string relativePath = this.fileSystem.FileInfo.FromFileName(this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot)).Directory.FullName.ToLowerInvariant(); if (!this.fileSystem.Directory.Exists(relativePath)) { this.fileSystem.Directory.CreateDirectory(relativePath); } Uri relativeFilePath = ditaMapPathGenerator.GeneratePathToFeature(featureNode); string filename = this.fileSystem.Path.Combine(relativePath, this.fileSystem.Path.GetFileName(relativeFilePath.ToString())); var document = new XDocument(new XDocumentType("topic", "-//OASIS//DTD DITA Topic//EN", "topic.dtd", string.Empty), topic); document.Save(filename); }
public void Setup() { this.testFeature = new Feature { Name = "Test" }; this.featureFileInfo = this.FileSystem.FileInfo.FromFileName(FileSystem.Path.Combine(RootPath, FeaturePath)); this.featureDirectoryNode = new FeatureNode(this.featureFileInfo, RelativePath, this.testFeature); this.featureWithMeta = new JsonFeatureWithMetaInfo(this.featureDirectoryNode); }
public void Setup() { this._testFeature = new Feature { Name = "Test" }; this._featureFileInfo = this.RealFileSystem.FileInfo.FromFileName(MockFileSystem.Path.Combine(ROOT_PATH, FEATURE_PATH)); this._featureDirectoryNode = new FeatureNode(this._featureFileInfo, RELATIVE_PATH, this._testFeature); this._featureWithMeta = new FeatureWithMetaInfo(this._featureDirectoryNode); }
public void FeatureStarted(string title, string description) { var feature = new FeatureNode() { Title = title, Description = description, }; _report.Features.Add(feature); }
protected TreeNode CreateTreeNode(FeatureNode node) { var treeNode = new TreeNode(node.Info.Name) { Name = node.Info.Name }; ResetFeatureNode(node.Info, treeNode); return(treeNode); }
public void Then_can_view_directory_node_successfully() { var directory = new DirectoryInfo(@"c:\directory"); var node = new FeatureNode { Location = directory, Url = new Uri(directory.FullName), }; Assert.AreEqual(FeatureNodeType.Directory, node.Type); }
public void Then_can_view_unknown_node_successfully() { var file = new FileInfo(@"c:\directory\my.txt"); var node = new FeatureNode { Location = file, Url = new Uri(file.FullName), }; Assert.AreEqual(FeatureNodeType.Unknown, node.Type); }
/// <summary> /// Handles service/feature selection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvFeatures_AfterCheck(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; FeatureNode featureNode = (FeatureNode)node.Tag; System.Diagnostics.Debug.WriteLine( string.Format("tvFeatures_AfterCheck [processing] {0}", node.Text)); // update list of selected features if (node.Checked) { if (!_features.Contains(featureNode.Feature)) { _features.Add(featureNode.Feature); } } else { _features.RemoveAll(v => (v == featureNode.Feature)); } if (e.Action != TreeViewAction.ByMouse && e.Action != TreeViewAction.ByKeyboard) { System.Diagnostics.Debug.WriteLine(string.Format("{0} checked automatically - skip part of processing", featureNode.DisplayName)); return; } System.Diagnostics.Debug.WriteLine(string.Format(" --- check feature {0}", featureNode.DisplayName)); featureNode.Checked = node.Checked; FeaturesSet.UpdateChildFeatures(featureNode); SetupChildFeatures(featureNode); // for PTZ Configurable Home / Fixed Home: // only one feature can be implemented if (featureNode.Feature == Feature.PTZConfigurableHome && node.Checked) { _featureNodes[Feature.PTZFixedHome].Checked = false; } else if (featureNode.Feature == Feature.PTZFixedHome && node.Checked) { _featureNodes[Feature.PTZConfigurableHome].Checked = false; } else if (featureNode.Feature == Feature.PTZHome && featureNode.Checked) { if (!(_featureNodes[Feature.PTZConfigurableHome].Checked || _featureNodes[Feature.PTZFixedHome].Checked)) { _featureNodes[Feature.PTZConfigurableHome].Checked = true; } } }
public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument() { var fakeHtmlFeatureFormatter = Substitute.For <IHtmlFeatureFormatter>(); var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter, new HtmlIndexFormatter()); var featureNode = new FeatureNode( FileSystem.FileInfo.FromFileName(@"c:\temp\test.feature"), ".", new Feature()); formatter.Format(featureNode, new INode[0]); fakeHtmlFeatureFormatter.Received().Format(featureNode.Feature); }
public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument() { var fakeHtmlFeatureFormatter = new Mock <IHtmlFeatureFormatter>(); var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, new HtmlIndexFormatter()); var featureNode = new FeatureNode( FileSystem.FileInfo.FromFileName(@"c:\temp\test.feature"), ".", new Feature()); formatter.Format(featureNode, new INode[0]); fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature)); }
public XElement Format(FeatureNode featureNode) { var xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml"); if (featureNode.Type == FeatureNodeType.Feature) { return this.htmlFeatureFormatter.Format(featureNode.Feature); } else if (featureNode.Type == FeatureNodeType.Markdown) { return this.htmlMarkdownFormatter.Format(File.ReadAllText(featureNode.Location.FullName)); } throw new InvalidOperationException("Cannot format a FeatureNode with a Type of " + featureNode.Type + " as content"); }
public FeatureEdge(FeatureNode l, FeatureNode r, SubScoreFactory scoringParams) { LNode = l; RNode = r; var ri = r.Feature == null ? 0.0 : r.Feature.IntensityMax; var li = l.Feature == null ? 0.0 : l.Feature.IntensityMax; _scoringParams = scoringParams; if (LNode is PrecursorFeatureNode) // TODO fix later when no summed intensity is used _ratio = GetRatioIndex(ri, ri); else _ratio = GetRatioIndex(li, ri); Weight = GetWeight(); }
public void ThenCanGeneratePathToTopLevelFeatureFileSuccessfully() { var configuration = Container.Resolve <Configuration>(); configuration.FeatureFolder = FileSystem.DirectoryInfo.FromDirectoryName(@"c:\features"); var featureNode = new FeatureNode(FileSystem.FileInfo.FromFileName(@"c:\features\the_feature.feature"), @"features\the_feature.feature", new Feature { Name = "The Feature" }); var ditaMapPathGenerator = Container.Resolve <DitaMapPathGenerator>(); Uri existingUri = ditaMapPathGenerator.GeneratePathToFeature(featureNode); existingUri.OriginalString.ShouldEqual(@"the_feature.dita"); }
public void Format_ContentIsFeatureNode_UsesHtmlFeatureFormatterWithCorrectArgument() { var fakeHtmlFeatureFormatter = new Mock <IHtmlFeatureFormatter>(); var fakeHtmlImageRelocator = new Mock <HtmlImageRelocator>(null, null); fakeHtmlImageRelocator.Setup(x => x.Relocate(It.IsAny <INode>(), It.IsAny <XElement>())); var formatter = new HtmlContentFormatter(fakeHtmlFeatureFormatter.Object, Container.Resolve <HtmlIndexFormatter>(), fakeHtmlImageRelocator.Object); var featureNode = new FeatureNode( MockFileSystem.FileInfo.FromFileName(@"c:\temp\test.feature"), ".", new Feature()); formatter.Format(featureNode, new INode[0]); fakeHtmlFeatureFormatter.Verify(f => f.Format(featureNode.Feature)); }
/// <summary> /// Forbids features selection/deselection when necessary. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvFeatures_BeforeCheck(object sender, TreeViewCancelEventArgs e) { if (_featuresReadOnly) { e.Cancel = true; return; } if (e.Action == TreeViewAction.ByMouse || e.Action == TreeViewAction.ByKeyboard) { TreeNode node = e.Node; FeatureNode featureNode = (FeatureNode)node.Tag; if (featureNode.State != FeatureState.Optional || featureNode.Enabled == false) { e.Cancel = true; } } }
/// <summary> /// Sets up device features after device type is changed. /// </summary> void SetupDeviceFeatures() { System.Diagnostics.Debug.WriteLine("Update features tree after device types selection"); foreach (TreeNode treeNode in tvFeatures.Nodes) { FeatureNode node = treeNode.Tag as FeatureNode; if (node != null) { System.Diagnostics.Debug.WriteLine( string.Format("Feature: {0}, State: {1}, Checked: {2}, Enabled (local): {3}", node.DisplayName, node.State, node.Checked, node.Enabled)); TransmitProperties(node, treeNode); } SetupChildFeatures(node); } }
/// <summary> /// Finds node for feature specified /// </summary> /// <param name="feature"></param> /// <returns></returns> public FeatureNode FindNode(Feature feature) { foreach (FeatureNode node in Nodes) { if (node.Feature == feature) { return(node); } else { FeatureNode n = FindNode(node, feature); if (n != null) { return(n); } } } return(null); }
private FeatureNode FindNode(FeatureNode node, Feature feature) { foreach (FeatureNode child in node.Nodes) { if (child.Feature == feature) { return(child); } else { FeatureNode n = FindNode(child, feature); if (n != null) { return(n); } } } return(null); }
public void Format(Body body, FeatureNode featureNode) { Feature feature = featureNode.Feature; body.InsertPageBreak(); if (this.configuration.HasTestResults) { TestResult testResult = this.nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.GenerateParagraph("Passed", "Passed"); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.GenerateParagraph("Failed", "Failed"); } } body.GenerateParagraph(feature.Name, "Heading1"); this.wordDescriptionFormatter.Format(body, feature.Description); if (feature.Background != null) { this.wordBackgroundFormatter.Format(body, feature.Background); } foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { this.wordScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { this.wordScenarioOutlineFormatter.Format(body, scenarioOutline); } } }
public FeatureEdge(FeatureNode l, FeatureNode r, SubScoreFactory scoringParams) { LNode = l; RNode = r; var ri = r.Feature == null ? 0.0 : r.Feature.IntensityMax; var li = l.Feature == null ? 0.0 : l.Feature.IntensityMax; _scoringParams = scoringParams; if (LNode is PrecursorFeatureNode) // TODO fix later when no summed intensity is used { _ratio = GetRatioIndex(ri, ri); } else { _ratio = GetRatioIndex(li, ri); } Weight = GetWeight(); }
public void New_Documentation_With_Feature_Produces_Single_Page() { var simpleFeature = new Feature(); simpleFeature.Name = "My Feature"; var relPath = "fakedir"; var location = fileSystem.FileInfo.FromFileName(@"c:\"); var newNode = new FeatureNode(location, relPath, simpleFeature); var featureTree = new Tree(new FolderNode(location, relPath)); featureTree.Add(newNode); var documentation = new Documentation(featureTree); var actualPageCount = documentation.PageCount; var actualPage = documentation.CurrentPage.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); Assert.AreEqual(1, documentation.PageCount); Assert.Contains("# Features", actualPage); Assert.Contains("### My Feature", actualPage); }
/// <summary> /// Convert a list Feature to node /// </summary> /// <param name="list">List feature</param> /// <returns>Feature nodes</returns> private IEnumerable <FeatureNode> ConvertFeatureToNode(IEnumerable <Feature> features) { var list = new List <FeatureNode>(); foreach (var f in features) { var fn = new FeatureNode { Id = f.Id_ChucNang, Subtitle = f.Tooltip, Title = f.Ten_ChucNang, Type = "Feature", Children = (f.Children == null || f.Children.Count() == 0) ? null : ConvertFeatureToNode(f.Children) }; list.Add(fn); } return(list); }
private static void TrainLibLinearProblemAndSveModel(SolverType liblinearSolver, double liblinearC, double liblinearEps, FeatureStatisticsDictionaryBuilder featureStatisticsDictBuilder, string trainDataModelFileName, FeatureNode[][] problemXTrain, double[] problemYTrain) { //Create liblinear problem var problem = new Problem(); problem.l = problemXTrain.Length; problem.n = featureStatisticsDictBuilder.FeatureInfoStatistics.Count; problem.x = problemXTrain; problem.y = problemYTrain; Console.WriteLine("Training a classifier with {0} items...", problemXTrain.Length); DateTime timeStart = DateTime.Now; var parameter = new Parameter(liblinearSolver, liblinearC, liblinearEps); Model model = Linear.train(problem, parameter); Console.WriteLine("Done - {0}", (DateTime.Now - timeStart)); var modelFile = new java.io.File(trainDataModelFileName); model.save(modelFile); Console.WriteLine("Train data model saved to {0}", trainDataModelFileName); }
private static void SetLibLinearProblemXandYFromSparseItems(List<SparseItemInt> items, out FeatureNode[][] problemX, out double[] problemY) { List<FeatureNode[]> problemXList = new List<FeatureNode[]>(); List<double> problemYList = new List<double>(); foreach (var item in items) { FeatureNode[] itemFeatureNodes = ProcessingHelpers.ConvertToSortedFeatureNodeArray(item.Features); problemXList.Add(itemFeatureNodes); problemYList.Add(item.Label); } problemX = problemXList.ToArray(); problemY = problemYList.ToArray(); }