public void ShouldParseNoParameters() { var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(new string[0]); Assert.That(paramDict, Is.Empty); }
public void ParaseArguments_Assigns_values() { var testAddress = "testAddress"; var testUser = "******"; var testPass = "******"; var testDirectory = "C:\asdasd"; var testToken = "asdagsdghADFSGesg"; var args = new List<string>() { "-address", testAddress, "-user", testUser, "-password", testPass, "-directory", testDirectory, "-token", testToken }; var argumentsParser = new ArgumentsParser(args); Assert.That(testAddress, Is.EqualTo(argumentsParser.Address)); Assert.That(testUser, Is.EqualTo(argumentsParser.User)); Assert.That(testPass, Is.EqualTo(argumentsParser.Password)); Assert.That(testDirectory, Is.EqualTo(argumentsParser.Directory)); Assert.That(testToken, Is.EqualTo(argumentsParser.ApiToken)); }
public void Parsing_MailFrom_EmailOnly() { ArgumentsParser args = new ArgumentsParser("<*****@*****.**> ARG1 ARG2"); Assert.Equal("<*****@*****.**>", args.Arguments[0]); Assert.Equal("ARG1", args.Arguments[1]); Assert.Equal("ARG2", args.Arguments[2]); }
public void Parsing_MailFrom_WithDisplayName() { ArgumentsParser args = new ArgumentsParser("<Robert Wood<*****@*****.**>> ARG1 ARG2"); Assert.Equal("<Robert Wood<*****@*****.**>>", args.Arguments[0]); Assert.Equal("ARG1", args.Arguments[1]); Assert.Equal("ARG2", args.Arguments[2]); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { var pargs = new ArgumentsParser(args); var runServer = pargs.GetValue<bool>("Server"); var runClient = pargs.GetValue<bool>("Client"); var serverService = new FlexibleProxyServerService(); var clientService = new FlexibleProxyClientService(); if (Environment.UserInteractive) { Console.WriteLine("Starting SERVER Service..."); serverService.OnServiceStart(args); Console.WriteLine("SERVER is started in console."); Console.WriteLine("Starting CLIENT Service..."); clientService.OnServiceStart(args); Console.WriteLine("CLIENT is started in console."); Console.WriteLine("Press ENTER to stop services and exit."); Console.ReadLine(); serverService.OnServiceStop(); clientService.OnServiceStop(); Console.WriteLine("Both services are stopped."); } else { var servicesToRun = new List<ServiceBase>(); if (runServer) servicesToRun.Add(serverService); if (runClient) servicesToRun.Add(clientService); ServiceBase.Run(servicesToRun.ToArray()); } }
public void ParseTest() { var parser = new ArgumentsParser(new[] { "-Arg1", "Value1", "-Arg2", "/Arg3", "Value2" }); Assert.IsTrue(parser.GetValue<bool>("Arg2")); Assert.AreEqual(parser.GetValue<string>("Arg1"), "Value1"); Assert.AreEqual(parser.GetValue<string>("Arg3"), "Value2"); }
public void Test_ParseCompressMode_WrongValue() { var args = new[] { "decompress111", "input", "output" }; var service = new ArgumentsParser(_fileService.Object); Assert.Throws <ArgumentException>(() => service.Parse(args)); }
public void Test_ParseBlockSize_CannotParseValue() { var args = new[] { "compress", "input", "output", "--block-size", "qqq" }; var service = new ArgumentsParser(_fileService.Object); Assert.Throws <ArgumentException>(() => service.Parse(args)); }
public void Test_ArgsLengthLessThanThree() { var args = new[] { "compress", "input" }; var service = new ArgumentsParser(_fileService.Object); Assert.Throws <ArgumentException>(() => service.Parse(args)); }
public void Test_IgnoreUnknownArgs() { var args = new[] { "compress", "input", "output", "unknown" }; var service = new ArgumentsParser(_fileService.Object); service.Parse(args); }
private PacketContent PaymentInstructionCashAction(SerializedInfo request, Token token) { var args = ArgumentsParser.Parse(request.Content); return(ClientService.PaymentInstructionCash(request.ClientInfo.Session, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) .ToPacketContent()); }
private PacketContent FundTransferAction(SerializedInfo request, Token token) { var args = ArgumentsParser.Parse(request.Content); return(ClientService.FundTransfer(request.ClientInfo.Session, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]) .ToPacketContent()); }
private PacketContent CallMarginExtensionAction(SerializedInfo request, Token token) { var args = ArgumentsParser.Parse(request.Content); return(ClientService.CallMarginExtension(request.ClientInfo.Session, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) .ToPacketContent()); }
public void When_ArgumentIsPotentialJson_IsCorrectlyIdentified() { string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3={test:123}" }; Operation[] operations = ArgumentsParser.Parse(args, ';'); Assert.IsTrue(operations[0].Arguments[2].IsPotentialJson); }
private IISBindingOptions Options(string commandLine) { var x = new IISBindingOptionsFactory(log, iis, helper); var optionsParser = new ArgumentsParser(log, plugins, commandLine.Split(' ')); var arguments = new ArgumentsService(log, optionsParser); return(x.Default(arguments)); }
public void ShouldParseBooleanParameterInMiddle() { var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(Params("/fast /file:afile.txt")); Assert.That(paramDict["file"], Is.EqualTo("afile.txt")); Assert.That(paramDict["fast"], Is.EqualTo("true")); }
private PacketContent UpdateQuotePolicyDetailAction(SerializedInfo request, Token token) { var args = ArgumentsParser.Parse(request.Content); TraderState state = SessionManager.Default.GetTradingConsoleState(request.ClientInfo.Session); return(Application.Default.TradingConsoleServer.UpdateQuotePolicyDetail(args[0].ToGuid(), args[1].ToGuid(), state) .ToPacketContent()); }
// Token: 0x060155A1 RID: 87457 RVA: 0x0056AF14 File Offset: 0x00569114 public void Execute(string strParams) { ArgumentsParser argumentsParser = new ArgumentsParser("i i", strParams); int @int = argumentsParser.GetInt32(0); int int2 = argumentsParser.GetInt32(1); Debug.Log((@int + int2).ToString()); }
public void Parsing_MailFrom_WithDisplayName() { ArgumentsParser args = new ArgumentsParser("<Robert Wood<*****@*****.**>> ARG1 ARG2"); Assert.AreEqual("<Robert Wood<*****@*****.**>>", args.Arguments[0]); Assert.AreEqual("ARG1", args.Arguments[1]); Assert.AreEqual("ARG2", args.Arguments[2]); }
public void Parsing_MailFrom_EmailOnly() { ArgumentsParser args = new ArgumentsParser("<*****@*****.**> ARG1 ARG2"); Assert.AreEqual("<*****@*****.**>", args.Arguments[0]); Assert.AreEqual("ARG1", args.Arguments[1]); Assert.AreEqual("ARG2", args.Arguments[2]); }
public void Should_be_able_to_Parse_multi_args_properly() { var arguments = ArgumentsParser.Parse <Arguments>(new[] { "-r", "localhost:8080", "-r", "localhost:8081", "-r", "localhost:8082" }); Assert.That(arguments.Registries, Contains.Item("localhost:8080")); Assert.That(arguments.Registries, Contains.Item("localhost:8081")); Assert.That(arguments.Registries, Contains.Item("localhost:8082")); }
public void Parsing_MailFrom_EmailOnly() { ArgumentsParser args = new ArgumentsParser("<*****@*****.**> ARG1 ARG2"); Assert.Equal("<*****@*****.**>", args.Arguments.First()); Assert.Equal("ARG1", args.Arguments.ElementAt(1)); Assert.Equal("ARG2", args.Arguments.ElementAt(2)); }
public void ShouldParseParametersWithSpaces() { var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(Params("/file afile.txt /name nobody")); Assert.That(paramDict["file"], Is.EqualTo("afile.txt")); Assert.That(paramDict["name"], Is.EqualTo("nobody")); }
private string?TestScript(string parameters) { var argParser = new ArgumentsParser(log, new MockPluginService(log), $"--scriptparameters {parameters} --verbose".Split(' ')); var args = argParser.GetArguments <ScriptArguments>(); return(args?.ScriptParameters); }
private IISOptions?Options(string commandLine) { var optionsParser = new ArgumentsParser(log, plugins, commandLine.Split(' ')); var arguments = new ArgumentsService(log, optionsParser); var x = new IISOptionsFactory(log, helper, arguments, userRoleService); return(x.Default().Result); }
public void Parsing_MailFrom_WithDisplayName() { ArgumentsParser args = new ArgumentsParser("<Robert Wood<*****@*****.**>> ARG1 ARG2"); Assert.Equal("<Robert Wood<*****@*****.**>>", args.Arguments.First()); Assert.Equal("ARG1", args.Arguments.ElementAt(1)); Assert.Equal("ARG2", args.Arguments.ElementAt(2)); }
public void When_SingleOperationWithNoArguments_Returns_OperationWithNoArguments() { string[] args = new string[] { "TestOperation" }; Operation[] operations = ArgumentsParser.Parse(args, ';'); Assert.AreEqual(0, operations[0].Arguments.Length); }
public void ParseTest() { var parser = new ArgumentsParser(new[] { "-Arg1", "Value1", "-Arg2", "/Arg3", "Value2" }); Assert.IsTrue(parser.GetValue <bool>("Arg2")); Assert.AreEqual(parser.GetValue <string>("Arg1"), "Value1"); Assert.AreEqual(parser.GetValue <string>("Arg3"), "Value2"); }
private PacketContent UpdateAccountsSettingAction(SerializedInfo request, Token token) { List <string> argList = ArgumentsParser.Parse(request.Content); Guid[] accountIds = argList[0].ToGuidArray(); return(AccountManager.Default.UpdateAccountSetting(request.ClientInfo.Session, accountIds) .ToPacketContent()); }
public void When_ArgumentIsNotPotentialJson_IsCorrectlyIdentified() { string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3=\"aaa bbbb\"" }; Operation[] operations = ArgumentsParser.Parse(args, ';'); Assert.IsFalse(operations[0].Arguments[1].IsPotentialJson); }
public void When_ArgumentIsString_IsCorrectlyIdentified() { string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3=\"aaa bbbb\"" }; Operation[] operations = ArgumentsParser.Parse(args, ';'); Assert.IsTrue(operations[0].Arguments[2].IsLiteralString); }
public void When_EmptyArgs_Returns_NoOperations() { string[] args = new string[0]; Operation[] operations = ArgumentsParser.Parse(args, ';'); Assert.AreEqual(0, operations.Length); }
private ManualOptions Options(string commandLine) { var x = new ManualOptionsFactory(log); var optionsParser = new ArgumentsParser(log, plugins, commandLine.Split(' ')); var arguments = new ArgumentsService(log, optionsParser); return(x.Default(arguments)); }
private ScriptOptions Options(string commandLine) { var optionsParser = new ArgumentsParser(log, plugins, commandLine.Split(' ')); var arguments = new ArgumentsService(log, optionsParser); var x = new ScriptOptionsFactory(log, arguments); var target = new Target(); return(x.Default(target).Result); }
public void When_SingleOperationWithSingleArgument_Returns_ArgumentWithCorrectValue() { string[] args = new string[] { "TestOperation", "Arg1=123" }; Operation[] Operations = ArgumentsParser.Parse(args); Assert.AreEqual(1, Operations[0].Arguments.Length); Assert.AreEqual("123", Operations[0].Arguments[0].Value); }
/// <summary> /// Implements strlen(). /// </summary> /// <param name="functionArgs">Arguments to the function.</param> /// <returns>Tuple - length of the string (str) and the data type (Numeric).</returns> public static Tuple <object, TokenType> StringLength(List <Tuple <object, TokenType> > functionArgs) { var argParser = new ArgumentsParser("strlen", 1, functionArgs); argParser.Validate(new[] { StringLiteral }); var(arg, _) = functionArgs[0]; return(new Tuple <object, TokenType>((double)((string)arg).Length, Numeric)); }
public void ParseDataArgumentsWordsOnly() { string testWords = "Greece, default, default, greece"; ArgumentsParser argParser = new ArgumentsParser(); argParser.Parse(new string[] { "http://www.cnn.com", testWords, "-w", }); Assert.False(argParser.CharsNumberNeeded); Assert.False(argParser.SentencesNeeded); Assert.False(argParser.Verbose); Assert.True(argParser.WordsNumberNeeded); }
public void ShouldParseBooleanParameterInMiddle() { var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(Params("/fast /file:afile.txt")); Assert.That(paramDict["file"], Is.EqualTo("afile.txt")); Assert.That(paramDict["fast"], Is.EqualTo("true")); Assert.That(Props.Get("file"), Is.EqualTo("afile.txt")); Assert.That(Props.Get("fast"), Is.EqualTo("true")); }
public void ShouldParseParametersWithSpaces() { var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(Params("/file afile.txt /name nobody")); Assert.That(paramDict["file"], Is.EqualTo("afile.txt")); Assert.That(paramDict["name"], Is.EqualTo("nobody")); Assert.That(Props.Get("file"), Is.EqualTo("afile.txt")); Assert.That(Props.Get("name"), Is.EqualTo("nobody")); }
public void GivenZeroArguments_ThenParseFails() { // Arrange var parser = new ArgumentsParser(new string[0]); // Act parser.Parse(); // Assert Assert.IsFalse(parser.Success); Assert.IsFalse(string.IsNullOrWhiteSpace(parser.ErrorMessage), "Error message must be populated"); }
public void GivenOneValidArgument_ThenParseSucceeds() { // Arrange var parser = new ArgumentsParser(new string[] { "one" }); // Act parser.Parse(); // Assert Assert.IsTrue(parser.Success); Assert.AreEqual("one", parser.Filename); }
public void ShouldParseParametersWithColons() { var args = Params("/file:afile.txt /name:nobody").ToList(); var parser = new ArgumentsParser(); var paramDict = parser.ParseParameters(args); Assert.That(paramDict["file"], Is.EqualTo("afile.txt")); Assert.That(paramDict["name"], Is.EqualTo("nobody")); Assert.That(Props.Get("file"), Is.EqualTo("afile.txt")); Assert.That(Props.Get("name"), Is.EqualTo("nobody")); }
public void ParseListOfUrlsTest() { string urlListPath = @"D:\github\web-scraper\Scraper\Scraper.Tests\TestData\UrlList.txt"; string[] expectedData = new string[] { "http://www.cnn.com", "http://www.cnn2.com", "http://www.cnn3.com" }; ArgumentsParser argParser = new ArgumentsParser(); argParser.Parse(new string[] { urlListPath }); Assert.AreEqual(3, argParser.Urls.Length); Assert.AreEqual(expectedData, argParser.Urls); }
public void ThrowsIfNonNamedArgumentFound() { var parser = new ArgumentsParser(); Assert.That(() => parser.ParseParameters(Params("afile.txt")), Throws.InstanceOf<NonNamedArgumentException>()); }
public void Parsing_FirstArgumentAferVerbWithColon_Split() { ArgumentsParser args = new ArgumentsParser("ARG1=VALUE:BLAH"); Assert.Equal(1, args.Arguments.Length); Assert.Equal("ARG1=VALUE:BLAH", args.Arguments[0]); }
public async Task ProcessAsync(IConnection connection, SmtpCommand command) { ArgumentsParser argumentsParser = new ArgumentsParser(command.ArgumentsText); if (argumentsParser.Arguments.Length > 0) { if (connection.Session.Authenticated) { throw new SmtpServerException(new SmtpResponse(StandardSmtpResponseCode.BadSequenceOfCommands, "Already authenticated")); } string mechanismId = argumentsParser.Arguments[0]; IAuthMechanism mechanism = AuthExtensionProcessor.MechanismMap.Get(mechanismId); if (mechanism == null) { throw new SmtpServerException( new SmtpResponse(StandardSmtpResponseCode.CommandParameterNotImplemented, "Specified AUTH mechanism not supported")); } if (!AuthExtensionProcessor.IsMechanismEnabled(mechanism)) { throw new SmtpServerException( new SmtpResponse(StandardSmtpResponseCode.AuthenticationFailure, "Specified AUTH mechanism not allowed right now (might require secure connection etc)")); } IAuthMechanismProcessor authMechanismProcessor = mechanism.CreateAuthMechanismProcessor(connection); string initialData = null; if (argumentsParser.Arguments.Length > 1) { initialData = string.Join(" ", argumentsParser.Arguments.Skip(1).ToArray()); } AuthMechanismProcessorStatus status = await authMechanismProcessor.ProcessResponseAsync(initialData); while (status == AuthMechanismProcessorStatus.Continue) { string response = await connection.ReadLineAsync(); if (response == "*") { await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments, "Authentication aborted")); return; } status = await authMechanismProcessor.ProcessResponseAsync(response); } if (status == AuthMechanismProcessorStatus.Success) { await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.AuthenticationOK, "Authenticated OK")); connection.Session.Authenticated = true; connection.Session.AuthenticationCredentials = authMechanismProcessor.Credentials; } else { await connection.WriteResponseAsync(new SmtpResponse(StandardSmtpResponseCode.AuthenticationFailure, "Authentication failure")); } } else { throw new SmtpServerException(new SmtpResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments, "Must specify AUTH mechanism as a parameter")); } }
public void ParseWordsList() { string testWords = "Greece, default, default, greece"; ArgumentsParser argParser = new ArgumentsParser(); argParser.Parse(new string[] { "http://www.cnn.com", testWords }); Assert.AreEqual(2, argParser.Words.Length); Assert.AreEqual(new string[] { "Greece", "default" }, argParser.Words); }
public void ParseWord() { string testWords = "Greece"; ArgumentsParser argParser = new ArgumentsParser(); argParser.Parse(new string[] { "http://www.cnn.com", testWords }); Assert.AreEqual(1, argParser.Words.Length); Assert.AreEqual(new string[] { testWords }, argParser.Words); }
public void ParseUrlTest() { string testUrl = "http://www.cnn.com"; ArgumentsParser argParser = new ArgumentsParser(); argParser.Parse(new string[] { testUrl }); Assert.AreEqual(1, argParser.Urls.Length); Assert.AreEqual(testUrl, argParser.Urls[0]); }