protected override void ProcessRecord() { if (!this.CheckFileExists(this.Filename)) { return; } this.WriteVerbose("Loading {0} as xml", this.Filename); var xmldoc = SXL.XDocument.Load(this.Filename); var root = xmldoc.Root; this.WriteVerbose("Root element name ={0}", root.Name); if (root.Name == "directedgraph") { this.WriteVerbose("Loading as a Directed Graph"); var dg_model = VA.Scripting.DirectedGraph.DirectedGraphBuilder.LoadFromXML( this.client, xmldoc); this.WriteObject(dg_model); } else if (root.Name == "orgchart") { this.WriteVerbose("Loading as an Org Chart"); var oc = VA.Scripting.OrgChart.OrgChartBuilder.LoadFromXML(this.client, xmldoc); this.WriteObject(oc); } else { var exc = new System.ArgumentException("Unknown root element for XML"); throw exc; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest(name = "V{0}") @ValueSource(longs = {999, -1}) void shouldThrowExceptionIfVersionIsUnknown(long protocolVersion) internal virtual void ShouldThrowExceptionIfVersionIsUnknown(long protocolVersion) { BoltStateMachineFactoryImpl factory = NewBoltFactory(); System.ArgumentException error = assertThrows(typeof(System.ArgumentException), () => factory.NewStateMachine(protocolVersion, _channel)); assertThat(error.Message, startsWith("Failed to create a state machine for protocol version")); }
public void PassingEmptyFirstStringComputeTest() { System.ArgumentException ex = Assert.Throws <System.ArgumentException>(() => Levenshtein.Compute(string.Empty, "sddss")); Assert.Contains("Input cannot be empty", ex.Message); }
protected override void ProcessRecord() { var targetshapes = new VisioScripting.TargetShapes(this.Shape); targetshapes.ResolveToSelection(this.Client); string ext = System.IO.Path.GetExtension(this.Filename).ToLowerInvariant(); if (!System.IO.File.Exists(this.Filename)) { this.WriteVerbose("File already exists"); if (this.Overwrite) { System.IO.File.Delete(this.Filename); } else { string msg = string.Format("File \"{0}\" already exists", this.Filename); var exc = new System.ArgumentException(msg); throw exc; } } if (_static_html_extensions.Contains(ext)) { this.Client.Export.ExportSelectionToHtml(VisioScripting.TargetSelection.Auto, this.Filename); } else { this.Client.Export.ExportSelectionToImage(VisioScripting.TargetSelection.Auto, this.Filename); } }
/* returns a random number without bias from within a range */ public ulong GetRandomInRange(ulong min, ulong max) { if (min > max) { System.ArgumentException argEx = new System.ArgumentException("Random number range: max smaller than min"); throw argEx; } else if (max == min) { /* Needed for init time because for some reason this function gets * called before any actual limits are set up, or something, and max and * min are both zero. */ return(min); } ulong maxOffset = max - min; ulong numIntervals = maxOffset + 1; ulong maxValid = System.UInt64.MaxValue - (System.UInt64.MaxValue % numIntervals); ulong intervalSize = maxValid / numIntervals; ulong trialNum; /* keep trying random numbers until we get one within the range that won't * causes biases */ do { trialNum = this.BaseCryptoRandom.GetRandomUInt64(); } while(trialNum > maxValid); return(min + (trialNum / intervalSize)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void stringOverExceedLimitNotAllowed() internal virtual void StringOverExceedLimitNotAllowed() { int length = MAX_TERM_LENGTH * 2; System.ArgumentException iae = assertThrows(typeof(System.ArgumentException), () => INSTANCE.validate(RandomStringUtils.randomAlphabetic(length))); assertThat(iae.Message, containsString("Property value size is too large for index. Please see index documentation for limitations.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void fileWatchRegistrationIsIllegal() internal virtual void FileWatchRegistrationIsIllegal() { DefaultFileSystemWatcher watcher = CreateWatcher(); System.ArgumentException exception = assertThrows(typeof(System.ArgumentException), () => watcher.Watch(new File("notADirectory"))); assertThat(exception.Message, containsString("Only directories can be registered to be monitored.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateExplicitIndexedRelationshipProperties() internal virtual void ValidateExplicitIndexedRelationshipProperties() { setUp(); Label label = Label.label("explicitIndexedRelationshipPropertiesTestLabel"); string propertyName = "explicitIndexedRelationshipProperties"; string explicitIndexedRelationshipIndex = "explicitIndexedRelationshipIndex"; RelationshipType indexType = RelationshipType.withName("explicitIndexType"); using (Transaction transaction = _database.beginTx()) { Node source = _database.createNode(label); Node destination = _database.createNode(label); Relationship relationship = source.CreateRelationshipTo(destination, indexType); _database.index().forRelationships(explicitIndexedRelationshipIndex).add(relationship, propertyName, "shortString"); transaction.Success(); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node source = _database.createNode(label); Node destination = _database.createNode(label); Relationship relationship = source.createRelationshipTo(destination, indexType); string longValue = StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1); _database.index().forRelationships(explicitIndexedRelationshipIndex).add(relationship, propertyName, longValue); transaction.Success(); } }); assertEquals("Property value size is too large for index. Please see index documentation for limitations.", argumentException.Message); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void parseDatabaseShouldThrowOnPath() internal virtual void ParseDatabaseShouldThrowOnPath() { Path path = Paths.get("data", "databases", GraphDatabaseSettings.DEFAULT_DATABASE_NAME); System.ArgumentException exception = assertThrows(typeof(System.ArgumentException), () => _arg.parse(Args.parse("--database=" + path))); assertEquals("'database' should be a name but you seem to have specified a path: " + path, exception.Message); }
protected override void ProcessRecord() { if (!System.IO.File.Exists(this.Filename)) { this.WriteVerbose("File already exists"); if (this.Overwrite) { System.IO.File.Delete(this.Filename); } else { var exc = new System.ArgumentException("File already exists"); throw exc; } } string ext = System.IO.Path.GetExtension(this.Filename).ToLowerInvariant(); if (ext == ".html" || ext == ".xhtml" || ext == ".htm") { this.client.Export.SelectionToSVGXHTML(this.Filename); } else { this.client.Export.SelectionToFile(this.Filename); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void nullToStringIsNotAllowed() internal virtual void NullToStringIsNotAllowed() { object testValue = mock(typeof(object)); when(testValue.ToString()).thenReturn(null); System.ArgumentException iae = assertThrows(typeof(System.ArgumentException), () => INSTANCE.validate(testValue)); assertThat(iae.Message, containsString("has null toString")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void failToCreateWhenConfiguredFactoryNotFound() internal virtual void FailToCreateWhenConfiguredFactoryNotFound() { Config config = Config.defaults(GraphDatabaseSettings.LockManager, "notFoundManager"); System.ArgumentException exception = assertThrows(typeof(System.ArgumentException), () => createLockFactory(config, NullLogService.Instance)); assertEquals("No lock manager found with the name 'notFoundManager'.", exception.Message); }
public virtual void test_constructor_messageCause() { System.ArgumentException cause = new System.ArgumentException("Under"); PricingException test = new PricingException("Hello", cause); assertEquals(test.Message, "Hello"); assertEquals(test.InnerException, cause); }
protected internal override int countLessThan(System.IComparable value) { if (value == null) { System.ArgumentException e = new System.ArgumentException(); throw e; } return(countLessThan(value, root)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") @Test void defaultValuesShouldBeValidClassifiers() internal virtual void DefaultValuesShouldBeValidClassifiers() { foreach (string classifier in DEFAULT_CLASSIFIERS) { describeClassifier(classifier); } // Make sure the above actually catches bad classifiers System.ArgumentException exception = assertThrows(typeof(System.ArgumentException), () => describeClassifier("invalid")); assertEquals("Unknown classifier: invalid", exception.Message); }
protected override void ProcessRecord() { if (this.Filename == null) { throw new System.ArgumentNullException(nameof(this.Filename)); } if (!System.IO.File.Exists(this.Filename)) { this.WriteVerbose("File already exists"); if (this.Overwrite) { System.IO.File.Delete(this.Filename); } else { string msg = string.Format("File \"{0}\" already exists", this.Filename); var exc = new System.ArgumentException(msg); throw exc; } } if (_static_html_extensions == null) { _static_html_extensions = new HashSet <string> { ".html", ".htm", ".xhtml" }; } string ext = System.IO.Path.GetExtension(this.Filename).ToLowerInvariant(); if (this.Shapes == null) { // use the active selection } else { if (this.Shapes.Length < 1) { throw new System.ArgumentOutOfRangeException(nameof(this.Shapes), "Shapes parameter must contain at least one shape"); } this.Client.Selection.SelectShapes(this.Shapes); } if (_static_html_extensions.Contains(ext)) { this.Client.ExportSelection.ExportSelectionToHtml(this.Filename); } else { this.Client.ExportSelection.ExportSelectionToFile(this.Filename); } }
public override int Write() { if (this.Robot.Type() != bRobotBrand.UR) { System.ArgumentException argEx = new System.ArgumentException("Invalid robot type for program. Is it a UR robot?"); throw argEx; } this.program = "def " + this.name + "():\n"; // Write init data this.program += "\ttextmsg(\"---\")\n"; this.program += "\ttextmsg(\"Program generated by Brick v0.1\")\n"; this.program += "\ttextmsg(\"Brick is written by Tom Svilans\")\n\n"; this.program += "\ttextmsg(\"tomsvilans.com\")\n\n"; this.program += "\ttextmsg(\"---\")\n"; Types.UR.AxisAngle ta = new Types.UR.AxisAngle(robot.Tool.RootToTCP); this.program += String.Format("\tset_tcp(p[{0:0.0000}, {1:0.0000}, {2:0.0000}, {3:0.0000}, {4:0.0000}, {5:0.0000}])\n", robot.Tool.RootToTCP.M03 * 0.001, robot.Tool.RootToTCP.M13 * 0.001, robot.Tool.RootToTCP.M23 * 0.001, ta.x * ta.angle, ta.y * ta.angle, ta.z * ta.angle); this.program += String.Format("\tset_payload({0:0.0000})\n\n", 1.0); //this.program += String.Format("while(True):\n\tif(get_digital_out({0})):\n\t\tbreak\n\telse:\n\t\tsync()\n\n", 5); for (int i = 0; i < commands.Count; ++i) { switch (commands[i].Type()) { case (CommandType.MoveCommand): bMoveBase movcmd = (bMoveBase)commands[i]; movcmd.Transform(Transform.PlaneToPlane(robot.Position, Plane.WorldXY)); this.program += " " + movcmd.to_script(bRobotBrand.UR, true); movcmd.Transform(Transform.PlaneToPlane(Plane.WorldXY, robot.Position)); break; case (CommandType.IOCommand): bIOBase iocmd = (bIOBase)commands[i]; this.program += iocmd.to_script(bRobotBrand.UR); break; default: this.program += "Unsupported command.\n"; break; } } this.program += "end\n"; this.program += this.name + "()\n"; // run program return 1; }
public new void isprazni(int komada) { if (popunjenost-komada < 0) { System.ArgumentException prazanSpremnik = new System.ArgumentException("Kontejner je prazan"); throw prazanSpremnik; } else { if (komada < 5 || komada > 10) { System.ArgumentException kriviBrojPraznjenjaKomada = new System.ArgumentException("Previše ili premalo komada"); throw kriviBrojPraznjenjaKomada; } else { popunjenost -= komada; } } }
public new void dodaj(int komada) { if (popunjenost + komada > kapacitet) { System.ArgumentException popunjenSpremnik = new System.ArgumentException("Kontejner je pun"); throw popunjenSpremnik; } else { { if (komada < 5 || komada > 10) { System.ArgumentException kriviBrojKomada = new System.ArgumentException("Previše ili premalo komada"); throw kriviBrojKomada; } else { popunjenost += komada; } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateIndexedNodePropertiesInLucene() internal virtual void ValidateIndexedNodePropertiesInLucene() { setUp(default_schema_provider.name(), GraphDatabaseSettings.SchemaIndex.NATIVE10.providerName()); Label label = Label.label("indexedNodePropertiesTestLabel"); string propertyName = "indexedNodePropertyName"; CreateIndex(label, propertyName); using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1)); transaction.success(); } }); assertThat(argumentException.Message, equalTo("Property value size is too large for index. Please see index documentation for limitations.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateIndexedNodePropertiesInNativeBtree() internal virtual void ValidateIndexedNodePropertiesInNativeBtree() { setUp(); Label label = Label.label("indexedNodePropertiesTestLabel"); string propertyName = "indexedNodePropertyName"; CreateIndex(label, propertyName); using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.setProperty(propertyName, StringUtils.repeat("a", keyValueSizeCapFromPageSize(PAGE_SIZE) + 1)); transaction.success(); } }); assertThat(argumentException.Message, containsString("is too large to index into this particular index. Please see index documentation for limitations.")); }
public InvalidUseException(string message, System.ArgumentException innerException) : base(message, innerException) { }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void nullIsNotAllowed() internal virtual void NullIsNotAllowed() { System.ArgumentException iae = assertThrows(typeof(System.ArgumentException), () => INSTANCE.validate(null)); assertEquals(iae.Message, "Null value"); }
public static System.ArgumentException ReadArgumentException(this MemoryBuffer buffer) { System.String _message = buffer.ReadAString(); var result = new System.ArgumentException(_message); return result; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldObjectIfTheArchiveArgumentIsMissing() internal virtual void ShouldObjectIfTheArchiveArgumentIsMissing() { System.ArgumentException exception = assertThrows(typeof(System.ArgumentException), () => (new DumpCommand(_homeDir, _configDir, null)).execute(new string[] { "--database=something" })); assertEquals("Missing argument 'to'", exception.Message); }
public void GivenIWork81HoursAtARateOf10_ThenAnExceptionIsRaised() { WageCalculator calculator = new WageCalculator(); System.ArgumentException argumentException = Assert.Throws <System.ArgumentException>(() => calculator.CalculateWages(81, 10)); }
public override int Write() { if (this.Robot.Type() != bRobotBrand.KUKA) { System.ArgumentException argEx = new System.ArgumentException("Invalid robot type for program. Is it a KUKA robot?"); throw argEx; } // GET INIT DATA this.program = ""; this.acceleration = 100; this.velocity = 100; // Compile robot program /* HEADER */ //this.program = "&ACCESS RVO\n"; this.program = "DEF " + this.name + "()\n"; this.program += "; Program generated by Brick v0.1\n; Brick is written by Tom Svilans\n; tomsvilans.com\n\n"; /* INITIALIZATION */ /* replace with proper joint max velocities and speeds */ this.program += String.Format("INT I\nBAS (#INITMOV,0 )\nFOR I = 1 TO 6\n$VEL_AXIS[I] = {0}\n$ACC_AXIS[I] = {1}\n$VEL_EXTAX[I] = {0}\n$ACC_EXTAX[I] = {1}\nENDFOR\n\n", this.velocity, this.acceleration); /* set mode to 'tool on robot' */ this.program += "$IPO_MODE = #BASE\n"; /* replace with radius */ this.program += String.Format("$APO.CDIS = {0}\n", 100); // approximate distance this.program += String.Format("$APO.CVEL = {0}\n", 100); // approximate velocity /* set advance pointer */ this.program += String.Format("$ADVANCE = {0}\n", 3); /* set tool data */ //this.program += String.Format("TOOL_DATA[{0}] = ", 14) + "{" + String.Format("X {0}, Y {1}, Z {2}, A {3}, B {4}, C {5}", 0, 0, 0, 0, 0, 0) + "}\n"; // set tool number and offset frame //this.program += String.Format("$TOOL = TOOL_DATA[{0}]\n", 1); // tool number /* get tool parameters */ Types.KUKA.kukaABC ttr = new Types.KUKA.kukaABC(robot.Tool.RootToTCP); this.program += "$TOOL = {" + String.Format("X {0}, Y {1}, Z {2}, A {3}, B {4}, C {5}", ttr.x, ttr.y, ttr.z, ttr.a, ttr.b, ttr.c) + "}\n"; //this.program += "$TOOL = {" + String.Format("X {0}, Y {1}, Z {2}, A {3}, B {4}, C {5}", 0, 0, 0, 30, 0, 0) + "}\n"; // tool number /* set base data */ this.program += String.Format("BASE_DATA[{0}]", 17) + " = {" + String.Format("X {0}, Y {1}, Z {2}, A {3}, B {4}, C {5}", 0, 0, 0, 0, 0, 0) + "}\n"; /* activate base */ this.program += String.Format("$BASE = BASE_DATA[{0}]\n", 17); // use base 17 as 0 base /* active base with external axis */ //this.program += String.Format("$BASE = EK(MACHINE_DEF[2].ROOT, MACHINE_DEF[2].MECH_TYPE, BASE_DATA[{0}]: ", 17) + "{x 0, y 0, z 0, a 0, b 0, c 0})\n"; // use base 17 as 0 base this.program += "\n"; // breathing room... /* replace with initial acceleration */ this.program += String.Format("$ACC.CP = {0}\n", this.acceleration * 0.006); /* replace with initial velocity */ this.program += String.Format("$VEL.CP = {0}\n", this.velocity * 0.002); this.program += String.Format("$VEL.ORI1 = {0}\n", (int)(this.velocity / 3)); this.program += String.Format("$ACC.ORI1 = {0}\n", (int)(this.acceleration / 2)); this.program += String.Format("$VEL.ORI2 = {0}\n", (int)(this.velocity / 3)); this.program += String.Format("$ACC.ORI2 = {0}\n", (int)(this.acceleration / 2)); //this.program += "$H_POS = {" + String.Format("A1 {0}, A2 {1}, A3 {2}, A4 {3}, A5 {4}, A6 {5},", // 0, -80, 120, 0, -40, 0) + // String.Format(" E1 0, E2 0, E3 0, E4 0, E5 0, E6 0, T '{0}', S '{1}'", 0, 0) + "}\n"; double r2d = 180.0 / Math.PI; this.program += "$H_POS = {" + String.Format("A1 {0}, A2 {1}, A3 {2}, A4 {3}, A5 {4}, A6 {5},", qHome[0] * r2d, qHome[1] * r2d, qHome[2] * r2d, qHome[3] * r2d, qHome[4] * r2d, qHome[5] * r2d) + " E1 0, E2 0, E3 0, E4 0, E5 0, E6 0}\n"; this.program += "PTP $H_POS\n\n"; // go to home position /* WRITE COMMANDS */ /* set current velocity and acceleration values, if they differ, write speed command too */ int last = this.commands.Count - 1; for (int i = 0; i < this.commands.Count; ++i) { switch (this.commands[i].Type()) { case (CommandType.MoveCommand): /* cast command as MoveCommand */ bMoveBase movcmd = (bMoveBase)this.commands[i]; /* handle continuous movements */ bool cont = true; if (i < last) { if (this.commands[i + 1].Type() == CommandType.MoveCommand) { /* check if next move is a stop move (not continuous) */ bMoveBase movnxt = (bMoveBase)this.commands[i + 1]; if (movnxt.MovementType() == bMoveBase.MoveType.Stop) cont = false; } } /* if it is the last command, not continous */ else cont = false; /* transform waypoint to local coordinates */ movcmd.Transform(Transform.PlaneToPlane(robot.Position, Plane.WorldXY)); /* where to put this? needs to go between below if-else block for splines... */ if ((movcmd.MovementType() != bMoveBase.MoveType.Stop) && (Math.Abs(movcmd.Velocity - this.velocity) > 0.0001)) { /* update current velocity to new one */ this.velocity = movcmd.Velocity; /* record change in velocity */ this.program += String.Format("$VEL.CP = {0}\n", this.velocity); // record change in velocity and convert from mm/s to m/s } /* handle spline moves */ if (movcmd.MovementType() == bMoveBase.MoveType.Process && !spline) { /* start spline block */ this.spline = true; this.program += "SPLINE\n"; } else if (movcmd.MovementType() != bMoveBase.MoveType.Process && spline) { /* end spline block */ this.program += "ENDSPLINE\n"; this.spline = false; } /* write command in KRL */ this.program += movcmd.to_script(bRobotBrand.KUKA, cont); /* put waypoint back into world space */ movcmd.Transform(Transform.PlaneToPlane(Plane.WorldXY, robot.Position)); break; case (CommandType.IOCommand): /* cast command as IOCommand */ bIOBase iocmd = (bIOBase)this.commands[i]; /* write command in KRL*/ this.program += iocmd.to_script(bRobotBrand.KUKA); break; } } if (this.spline) { /* if spline block is open, close it */ this.spline = false; this.program += "ENDSPLINE\n"; } /* return home and end it */ this.program += "PTP $H_POS\n\n"; this.program += "\nEND\n"; return 1; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldFailWhenAuthEnabledAndNoSecurityModuleFound() internal virtual void ShouldFailWhenAuthEnabledAndNoSecurityModuleFound() { System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => AbstractEditionModule.SetupSecurityModule(null, null, mock(typeof(Log)), null, "non-existent-security-module")); assertEquals("Failed to load security module with key 'non-existent-security-module'.", argumentException.Message); }