private byte[] TruncatedBy(byte[] buffer, int truncateAmount) { if (truncateAmount <= 0) { throw Tests_Values.new_ArgumentOutOfRangeException("truncateAmount", "Value must be a positive non-zero value."); } byte[] truncated = new byte[buffer.Length - truncateAmount]; Array.Copy(buffer, 0, truncated, 0, truncated.Length); return(truncated); }
public void CheckExceptionThrownByGetRemoteMachineName() { // Checking how the 'specified device not found' exception should be // created in GetRemoteMachineName. For some odd reason the MSFT NETCF // developer responsible for the initial implementation chose to throw // ArgumentOutOfRangeException. Note that its first parameter is // "paramName", so careful not to create a message that blames a // specific parameter name. // 1. // The following creates message: // Specified argument was out of the range of valid values. // Parameter name: No matching device discovered //throw new ArgumentOutOfRangeException("No matching device discovered"); // 2. // Good. :-) throw Tests_Values.new_ArgumentOutOfRangeException(null, "No matching device discovered."); }