public override bool Process (DataNode dataNode, ConsoleOptions options) { if (options.Values.Count == 0) return false; string jsonPath = options.Values[0]; using (FileStream stream = File.OpenWrite(jsonPath)) { using (StreamWriter writer = new StreamWriter(stream)) { if (dataNode is TagDataNode) { TagDataNode tagNode = dataNode as TagDataNode; WriteNbtTag(writer, tagNode.Tag); } else if (dataNode is NbtFileDataNode) { dataNode.Expand(); TagNodeCompound root = new TagNodeCompound(); foreach (DataNode child in dataNode.Nodes) { TagDataNode childTagNode = child as TagDataNode; if (childTagNode == null) continue; if (childTagNode.Tag != null) root.Add(childTagNode.NodeName, childTagNode.Tag); } WriteNbtTag(writer, root); } } } return true; }
public void SetUp() { assemblyOptions = new ConsoleOptions(new string[] { firstAssembly, secondAssembly }); fixtureOptions = new ConsoleOptions(new string[] { "-fixture:"+fixture, firstAssembly, secondAssembly }); }
public override bool Process(DataNode dataNode, ConsoleOptions options) { string value = options.Values[0]; TagDataNode tagDataNode = dataNode as TagDataNode; return tagDataNode.Parse(value); }
public void CanRecognizeBooleanOptions(string propertyName, string pattern) { Console.WriteLine("Testing " + propertyName); string[] prototypes = pattern.Split('|'); PropertyInfo property = GetPropertyInfo(propertyName); Assert.AreEqual(typeof(bool), property.PropertyType, "Property '{0}' is wrong type", propertyName); foreach (string option in prototypes) { ConsoleOptions options = new ConsoleOptions("-" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option); options = new ConsoleOptions("-" + option + "+"); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "+"); options = new ConsoleOptions("-" + option + "-"); Assert.AreEqual(false, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "-"); options = new ConsoleOptions("--" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize --" + option); options = new ConsoleOptions("/" + option); Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize /" + option); } }
public void FixtureNamePlusAssemblyIsValid() { ConsoleOptions options = new ConsoleOptions( "-fixture:NUnit.Tests.AllTests", "nunit.tests.dll" ); Assert.AreEqual("nunit.tests.dll", options.Parameters[0]); Assert.AreEqual("NUnit.Tests.AllTests", options.fixture); Assert.IsTrue(options.Validate()); }
public void HelpTextUsesCorrectDelimiterForPlatform() { string helpText = new ConsoleOptions().GetHelpText(); char delim = System.IO.Path.DirectorySeparatorChar == '/' ? '-' : '/'; string expected = string.Format( "{0}output=", delim ); StringAssert.Contains( expected, helpText ); expected = string.Format( "{0}out=", delim ); StringAssert.Contains( expected, helpText ); }
public override bool Process (DataNode dataNode, ConsoleOptions options) { Console.WriteLine(TypePrinter.Print(dataNode, options.ShowTypes)); if (dataNode.IsContainerType) { foreach (var child in dataNode.Nodes) Console.WriteLine(" | " + TypePrinter.Print(child, options.ShowTypes)); } return true; }
private void PrintSubTree (DataNode dataNode, ConsoleOptions options, string indent, bool last) { Console.WriteLine(indent + " + " + TypePrinter.Print(dataNode, options.ShowTypes)); indent += last ? " " : " |"; int cnt = 0; dataNode.Expand(); foreach (DataNode child in dataNode.Nodes) { cnt++; PrintSubTree(child, options, indent, cnt == dataNode.Nodes.Count); } }
public void ExcludeCategories() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "-exclude:Database;Slow" ); Assert.IsTrue( options.Validate() ); Assert.IsNotNull(options.exclude); Assert.AreEqual(options.exclude, "Database;Slow"); Assert.IsTrue(options.HasExclude); string[] categories = options.ExcludedCategories; Assert.IsNotNull(categories); Assert.AreEqual(2, categories.Length); Assert.AreEqual("Database", categories[0]); Assert.AreEqual("Slow", categories[1]); }
private void TestBooleanOption( string fieldName, string option ) { FieldInfo field = typeof(ConsoleOptions).GetField( fieldName ); Assert.IsNotNull( field, "Field '{0}' not found", fieldName ); Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName ); ConsoleOptions options = new ConsoleOptions( "-" + option ); Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option ); options = new ConsoleOptions( "--" + option ); Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option ); options = new ConsoleOptions( false, "/" + option ); Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option ); options = new ConsoleOptions( true, "/" + option ); Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option ); }
private void TestStringOption( string fieldName, string option ) { FieldInfo field = typeof(ConsoleOptions).GetField( fieldName ); Assert.IsNotNull( field, "Field {0} not found", fieldName ); Assert.AreEqual( typeof(string), field.FieldType ); ConsoleOptions options = new ConsoleOptions( "-" + option + ":text" ); Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize -" + option ); options = new ConsoleOptions( "--" + option + ":text" ); Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize --" + option ); options = new ConsoleOptions( false, "/" + option + ":text" ); Assert.AreEqual( null, (string)field.GetValue( options ), "Incorrectly recognized /" + option ); options = new ConsoleOptions( true, "/" + option + ":text" ); Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize /" + option ); }
public override bool Process (DataNode dataNode, ConsoleOptions options) { TagListDataNode listNode = dataNode as TagListDataNode; listNode.Clear(); foreach (string value in options.Values) { TagNode tag = TagDataNode.DefaultTag(listNode.Tag.ValueType); TagDataNode tagData = TagDataNode.CreateFromTag(tag); if (!tagData.Parse(value)) return false; if (!listNode.AppendTag(tagData.Tag)) return false; } return true; }
public void Run() { this.options = ConsoleOptions.ParseArgs(this.args); this.configuration = Configuration.LoadConfig(this.options.ConfigFile); if (this.configuration != null) { Logger.SetupLogger(this.configuration.Get[Configuration.LogConfigFilePath]); TestRunner.RunTests(this.configuration); } else { Console.WriteLine("Error. File config.xml not found or corrupted."); } if (this.options.Silent) return; Console.Write("Press any key to exit."); Console.ReadKey(); }
public ServoSorter( ICaptureGrab capture ,ConsoleOptions options) : base(capture) { _servoPosition = 70; Settings = options.ColourSettings; _debounceWatch = new Stopwatch(); var deviceFactory = new Pca9685DeviceFactory(); var device = deviceFactory.GetDevice(options.UseFakeDevice); SetLogLevel(device); _pwmControl = new ServoSortPwmControl(device); _pwmControl.Init(); _detector = new ColourDetector(); }
public override bool OptionsValid(ConsoleOptions options) { if (options.Values.Count == 0) return false; return true; }
public void XmlParameterWithoutFileNameIsInvalid() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "-xml:" ); Assert.IsFalse(options.Validate()); }
public void AllowForwardSlashDefaultsCorrectly() { ConsoleOptions options = new ConsoleOptions(); Assert.AreEqual( Path.DirectorySeparatorChar != '/', options.AllowForwardSlash ); }
public void NoParametersCount() { ConsoleOptions options = new ConsoleOptions(); Assert.IsTrue(options.NoArgs); }
public void FileNameWithoutXmlParameterLooksLikeParameter() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "result.xml" ); Assert.IsTrue(options.Validate()); Assert.AreEqual(2, options.Parameters.Count); }
public void XmlParameter() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "-xml:results.xml" ); Assert.IsTrue(options.ParameterCount == 1, "assembly should be set"); Assert.AreEqual("tests.dll", options.Parameters[0]); Assert.AreEqual("results.xml", options.xml); }
public string BuildCommandArgs(ConsoleOptions consoleOptions, bool debug) { StringBuilder commandArgsBuilder = new StringBuilder("run "); if (consoleOptions.Target == null) throw new InvalidOperationException(); commandArgsBuilder.AppendFormat("\"{0}\" ", consoleOptions.Target); if (consoleOptions.LogFile != null) commandArgsBuilder.AppendFormat("\"/logFile:{0}\" ", consoleOptions.LogFile); if (consoleOptions.BaseFolder != null) commandArgsBuilder.AppendFormat("\"/baseFolder:{0}\" ", consoleOptions.BaseFolder); if (consoleOptions.ReportFileName != null) commandArgsBuilder.AppendFormat("\"/reportFile:{0}\" ", consoleOptions.ReportFileName); if (consoleOptions.Filter != null) commandArgsBuilder.AppendFormat("\"/filter:{0}\" ", consoleOptions.Filter); commandArgsBuilder.Append("/toolIntegration:vs2010 "); if (debug) commandArgsBuilder.Append("/debug "); return commandArgsBuilder.ToString(); }
public void NoFixtureNameProvided() { ConsoleOptions options = new ConsoleOptions( "-fixture:", "nunit.tests.dll" ); Assert.IsFalse(options.Validate()); }
public void InvalidCommandLineParms() { ConsoleOptions options = new ConsoleOptions( "-garbage:TestFixture", "-assembly:Tests.dll" ); Assert.IsFalse(options.Validate()); }
public void InvalidOption() { ConsoleOptions options = new ConsoleOptions( "-asembly:nunit.tests.dll" ); Assert.IsFalse(options.Validate()); }
public void AssemblyAloneIsValid() { ConsoleOptions options = new ConsoleOptions( "nunit.tests.dll" ); Assert.IsTrue(options.Validate(), "command line should be valid"); }
public void TransformParameter() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "-transform:Summary.xslt" ); Assert.IsTrue(options.ParameterCount == 1, "assembly should be set"); Assert.AreEqual("tests.dll", options.Parameters[0]); Assert.AreEqual("Summary.xslt", options.transform); }
public override bool Process (DataNode dataNode, ConsoleOptions options) { PrintSubTree(dataNode, options, "", true); return true; }
public void XmlParameterWithFullPathUsingEqualSign() { ConsoleOptions options = new ConsoleOptions( "tests.dll", "-xml=C:/nunit/tests/bin/Debug/console-test.xml" ); Assert.IsTrue(options.ParameterCount == 1, "assembly should be set"); Assert.AreEqual("tests.dll", options.Parameters[0]); Assert.AreEqual("C:/nunit/tests/bin/Debug/console-test.xml", options.xml); }
public void AssemblyName() { ConsoleOptions options = new ConsoleOptions( "nunit.tests.dll" ); Assert.AreEqual( "nunit.tests.dll", options.Parameters[0] ); }
public void FileNameWithoutXmlParameterIsInvalid() { ConsoleOptions options = new ConsoleOptions( "tests.dll", ":result.xml" ); Assert.IsFalse(options.Validate()); }