public void unknownMethod() { const String source = @"- junk:"; InvalidArgumentException error = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source)); Assert.Equal("Pnyx method can not be found: junk", error.Message); }
public void headerNamesError(String message, params Object[] columnNumbersAndNames) { using (Pnyx p = new Pnyx()) { p.readString("bb"); p.parseCsv(hasHeader: true); InvalidArgumentException exception = Assert.Throws <InvalidArgumentException>(() => p.headerNames(columnNumbersAndNames)); Assert.Equal(message, exception.Message); } }
public void dictionaryParametersTooMany() { const String source = @" - readString: 'Mx trx miscarrx. Shx flx.' - sed: { 'flags': 'ig', 'pattern': 'x', 'replacement': 'y', 'junk': 'xxx' } "; InvalidArgumentException error = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source)); Assert.Equal("Unknown named parameters 'junk' for Pnyx method 'sed', which has parameters 'pattern,replacement,flags'", error.Message); }
public void dictionaryParametersMissingRequired() { const String source = @" - readString: 'Mx trx miscarrx. Shx flx.' - sed: { 'pattern': 'x' } "; InvalidArgumentException error = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source)); Assert.Equal("Pnyx method 'sed' is missing required parameter 'replacement'", error.Message); }
public void Fail_Main_BuildArgumentsValidationException() { // Setup var fakeValue = Fakes.RandomString(); var testException = new InvalidArgumentException($"{nameof(BuildArguments.ProtectionLevel)}", fakeValue); // Execute var exception = Record.Exception(() => Program.MainInternal(_builderMock.Object, new[] { $"-{nameof(BuildArguments.ProtectionLevel)}", fakeValue })); // Assert Assert.IsType<InvalidArgumentException>(exception); Assert.Equal(testException.Message, exception.Message, StringComparer.InvariantCultureIgnoreCase); }
public void Fail_Validate_InvalidProtectionLevel(string protectionLevelString) { // Setup var testException = new InvalidArgumentException(nameof(BuildArguments.ProtectionLevel), protectionLevelString); // Execute var exception = Record.Exception(() => new BuildArguments(null, null, null, protectionLevelString, null, null, Fakes.RandomString(), null, null)); // Assert Assert.NotNull(exception); Assert.IsType <InvalidArgumentException>(exception); Assert.Equal(exception.Message, testException.Message, StringComparer.InvariantCultureIgnoreCase); }
public static ServiceException ConvertException(Exception ex) { ServiceException result; switch (ex) { case ArgumentNullException argumentNullException: { result = new MissingArgumentException( message: "Request is missing argument.", innerException: argumentNullException); break; } case ArgumentException argumentException: { result = new InvalidArgumentException( message: "Request has an invalid argument.", innerException: argumentException); break; } case ServiceException serviceException: { result = serviceException; break; } default: { result = new InternalErrorException( message: "An internal error has occurred.", innerException: ex); break; } } return(result); }